From 9a33d05483bf23d5c4939f3becb01228cd7b7e87 Mon Sep 17 00:00:00 2001 From: Johan Rade Date: Thu, 24 Aug 2023 15:31:13 +0200 Subject: [PATCH] Linking error fix Fixes linking error when compiling with Visual Studio and including hnswlib.h in several cpp files. before: 2>Tools.lib(Pch.obj) : error LNK2005: "void __cdecl cpuid(int * const,int,int)" (?cpuid@@YAXQEAHHH@Z) already defined in Pch.obj 2>Tools.lib(NearestNeighbors.obj) : error LNK2005: "void __cdecl cpuid(int * const,int,int)" (?cpuid@@YAXQEAHHH@Z) already defined in Pch.obj 2>C:\Users\Rade\Documents\Data Analysis\Code\GenomicsLab Repo\x64\Release\ExpressionDemo.exe : fatal error LNK1169: one or more multiply defined symbols found 2>Done building project "ExpressionDemo.vcxproj" -- FAILED. after: 2>ExpressionDemo.vcxproj -> C:\Users\Rade\Documents\Data Analysis\Code\GenomicsLab Repo\x64\Release\ExpressionDemo.exe --- hnswlib/hnswlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hnswlib/hnswlib.h b/hnswlib/hnswlib.h index fb7118fa..ac2378e4 100644 --- a/hnswlib/hnswlib.h +++ b/hnswlib/hnswlib.h @@ -15,7 +15,7 @@ #ifdef _MSC_VER #include #include -void cpuid(int32_t out[4], int32_t eax, int32_t ecx) { +static void cpuid(int32_t out[4], int32_t eax, int32_t ecx) { __cpuidex(out, eax, ecx); } static __int64 xgetbv(unsigned int x) {