user12429628
user12429628

Reputation:

Already defined symbol (void * __cdecl operator new(unsigned __int64,void *) when using libmemcached

I'm creating and using libmemcached with Visual Studio. Since we have updated the compiler version operator new and new [] are defined in that library and I get errors when linking a DLL.

dumpbin /symbols microsoft_net_16_YlibmemcachedD.lib | grep new
1E4 00000FA6 SECT5F notype       Label        | $yynewstate$991
431 00000000 SECT3  notype ()    External     | ??2@YAPEAX_KPEAX@Z (void * __cdecl operator new(unsigned __int64,void *))
433 00000000 SECT7  notype ()    External     | ??_U@YAPEAX_KPEAX@Z (void * __cdecl operator new[](unsigned __int64,void *))

C:\Users\martin.gaeckler\ade\oss\cache\libmemcached\lib\nt_x64>ls -l
total 4420
-rw-r--r-- 1 martin.gaeckler Domain Users 2050100 Nov 16 12:37 microsoft_net_16_YlibmemcachedD.lib
-rw-r--r-- 1 martin.gaeckler Domain Users  217088 Nov 16 12:37 microsoft_net_16_YlibmemcachedD.pdb
-rw-r--r-- 1 martin.gaeckler Domain Users 2036636 Nov 16 12:37 microsoft_net_16_YlibmemcachedDS.lib
-rw-r--r-- 1 martin.gaeckler Domain Users  217088 Nov 16 12:37 microsoft_net_16_YlibmemcachedDS.pdb

C:\Users\martin.gaeckler\ade\oss\cache\libmemcached\lib\nt_x64>ls -l
total 4440
-rw-r--r-- 1 martin.gaeckler Domain Users 2060924 Nov 16 16:27 microsoft_net_16_YlibmemcachedD.lib
-rw-r--r-- 1 martin.gaeckler Domain Users  217088 Nov 16 16:27 microsoft_net_16_YlibmemcachedD.pdb
-rw-r--r-- 1 martin.gaeckler Domain Users 2047108 Nov 16 16:27 microsoft_net_16_YlibmemcachedDS.lib
-rw-r--r-- 1 martin.gaeckler Domain Users  217088 Nov 16 16:27 microsoft_net_16_YlibmemcachedDS.pdb

C:\Users\martin.gaeckler\ade\oss\cache\libmemcached\lib\nt_x64>dumpbin /symbols microsoft_net_16_YlibmemcachedD.lib | grep new
1E3 00000FB6 SECT5F notype       Label        | $yynewstate$991

When using the new library I'm getting errors:

link -libpath:"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30037/lib/x64" -libpath:"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30037/atlmfc/lib/x64" -libpath:"C:/Program Files (x86)/Windows Kits/10/lib/10.0.18362.0/ucrt/x64" -libpath:"C:/Program Files (x86)/Windows Kits/10/lib/10.0.18362.0/um/x64" -libpath:"C:/Program Files (x86)/Windows Kits/NETFXSDK/4.8/lib/um/x64" -nologo -out:nt_x64REL_microsoft_net_16_YD/adecache.dll -opt:ref -manifest:embed -manifestinput:"C:/Users/martin.gaeckler/ade/gradle/develop/version/compatibility.manifest" -manifestuac:"level='asInvoker' uiAccess='false'" -debug -release -dll -guard:cf -machine:X64 -subsystem:windows,6.00 -version:22.12 /NODEFAULTLIB:hosts.obj /NODEFAULTLIB:libmemcached.lib  C:/Users/martin.gaeckler/ade/lib/nt_x64/microsoft_net_16_YcacheE.lib ../libmemcached/lib/nt_x64/microsoft_net_16_YlibmemcachedD.lib "C:/Users/martin.gaeckler/ade/lib/nt_x64/microsoft_net_16_YmainD.obj" "C:/Users/martin.gaeckler/ade/lib/nt_x64/adegui.lib" kernel32.lib user32.lib gdi32.lib advapi32.lib iphlpapi.lib netapi32.lib secur32.lib setupapi.lib ws2_32.lib adsiid.lib activeds.lib mpr.lib imagehlp.lib version.lib ole32.lib oleaut32.lib uuid.lib shell32.lib shlwapi.lib propsys.lib comdlg32.lib comctl32.lib wininet.lib winspool.lib sfc.lib "C:/Users/martin.gaeckler/ade/gradle/apm/libsoftwaretelemetry-win32-x86_64/libsoftwaretelemetry.lib" nt_x64REL_microsoft_net_16_YD/adecache.res -def:nt_x64REL_microsoft_net_16_YD/adecache.def
   Creating library nt_x64REL_microsoft_net_16_YD\adecache.lib and object nt_x64REL_microsoft_net_16_YD\adecache.exp
microsoft_net_16_YlibmemcachedD.lib(hosts.obj) : error LNK2005: "void * __cdecl operator new(unsigned __int64,void *)" (??2@YAPEAX_KPEAX@Z) already defined in microsoft_net_16_YmainD.obj
nt_x64REL_microsoft_net_16_YD\adecache.dll : fatal error LNK1169: one or more multiply defined symbols found
make: *** [nt_x64REL_microsoft_net_16_YD/adecache.dll] Error 145

When using the option "LDFLAGS += /FORCE:MULTIPLE" it works. But I'm not sure whether this is a good solution. Any hints?

Upvotes: 0

Views: 326

Answers (0)

Related Questions