c++ linker error LNK2005 already defined in SDL - c++

I am compiling my program using VS2005. I am linking to SDL static libraries and am getting the following linker errors;
1>LIBCMTD.lib(fpinit.obj) : error LNK2005: __fltused already defined in SDL2d.lib(SDL_stdlib.obj)
1>LIBCMTD.lib(ftol2.obj) : error LNK2005: __ftol2_sse already defined in SDL2d.lib(SDL_stdlib.obj)
1> Creating library ..\..\..\product\VS2005\libs\\Standalone.lib and object ..\..\..\product\VS2005\libs\\Standalone.exp
1>..\..\..\product\VS2005\libs\\Standalone.exe : fatal error LNK1169: one or more multiply defined symbols found
I compiled SDL2d.lib using the same VS2005 compiler. My original thought was that I had mismatched runtime library settings for these projects. However after checking they are both set to Multi-Threaded Debug.
I have just noticed that the linker output above seems to be creating a Standalone.lib and Standalone.exp before making the Standalone.exe. I have no idea why it's making a .lib and .exp
Any other reasons why this error would occur?
Thanks

Needed to define HAVE_LIBC in the SDL project. This stopped the multiple redefinition of both _ftlused and _ftol2_sse

Related

Linking error after upgrading to VS2017U8 from VS2017U2

Our Visual C++ project was compiling and linking successfully when running with VS2017U2. I have made changes to a couple of make files in our project to make it compile with VS2017U8. After the change,I see that the compilation is successful but I am getting a linking error here -
2019-02-21 19:41:44 | libvcruntime.lib(std_type_info.obj) : error LNK2005: ___std_type_info_destroy_list already defined in vcruntime.lib(VCRUNTIME140.dll)
2019-02-21 19:41:44 | Creating library d:/build/ob/sb-21330799/sim-20fq1/sim/build/beta/apps/coreDump/coreDump.lib and object d:/build/ob/sb-21330799/sim-20fq1/sim/build/beta/apps/coreDump/coreDump.exp
2019-02-21 19:41:44 | coreDump.dll : fatal error LNK1169: one or more multiply defined symbols found
I have googled on this linking error (LNK2005) but what is strange is why I am getting this error after only doing VS update without doing any code changes? And how to resolve this? Any pointers on this appreciated.

Error while compiling a DLL - error LNK2005

I'd like to compile a DLL and I've got this error when I include <afxdb.h>:
error LNK2005: DllMain already defined in xlFunctions.obj
error LNK1169: one or more multiply defined symbols found
I do have a DllMain function in my xlfunctions.cpp this is the entry point of my DLL.
The Use of MFC property is set to Use MFC in a Shared DLL
How can I solve this error ?
Thanks

Is It possible to Linking static library into dynamic library in Visual Studio?

I am try to link a static library in a dynamic library tmxParser.lib in Visual Studio 2010 express. I have the static library set as a dependency of the dynamic library. When VS build the static library builds fine and creates tmxParser.lib. When VS builds the dynamic library I am getting linker errors. I tried to match the Runtime Library under property page -> Configuration properties -> C/C++ -> Code Generation
It doesn't help. Anyone have any idea?
2>LIBCMTD.lib(fopen.obj) : error LNK2005: _fopen already defined in s3e_d.lib(iwcrt_stdio.obj)
2>LIBCMTD.lib(open.obj) : error LNK2005: __open already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(open.obj) : error LNK2005: __sopen already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(chsize.obj) : error LNK2005: __chsize already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(read.obj) : error LNK2005: __read already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(close.obj) : error LNK2005: __close already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(lseek.obj) : error LNK2005: __lseek already defined in s3e_d.lib(iwcrt_win32.obj)
2>LIBCMTD.lib(setmode.obj) : error LNK2005: __setmode already defined in s3e_d.lib(iwcrt_win32.obj)
When you say you have it set as a dependency, do you mean you have it set as a Project Dependency or is under "Additional Dependencies" in
Project Properties -> Librarian->General -> Additional Dependencies
Generally, yes.
The problem you have seems to be that the library (is it the marmalade library?) implements some of the methods from the C++ runtime library. Probably, this lib is supposed to be used without linking the standard runtime library.
Possible solutions:
do not link c++ runtime in your DLL. That should be possible if you write just a thin wrapper
Ask the guys making the lib how they thought this is supposed to work
use the lib.exe or dumpbin.exe to:
extract all .obj files of the lib
remove the conflicting symbols from the .obj files
recreate the lib
The latter is obviously an ugly hack, and should be reserved for cases where neither source nor original developer are available anymore.

How can I use the IntelliProtector API in a win32 DLL program

I'm a beginner when it comes to DLLs. I've developed software that I'm trying to protect with the IntelliProtector API.
My question is this: How can I include such a library/source code (whatever you call it) into my software and have it compiled? I've added the files to my project, it then had some errors related to MFC dll. I Googled and changed settings to shared MFC dll.
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
Once I changed that, I now get this error:
fatal error LNK1169: one or more multiply defined symbols found
Which I believe is caused by 2 entry points? I can't really figure this one out; any help would be greatly appreciated.
I'm getting the following errors:
1>mfcs100d.lib(dllmodul.obj) : error LNK2005: _DllMain#12 already defined in dllmain.obj
1>E:\software\PokerLog\Debug\Poker.dll : fatal error LNK1169: one or more multiply defined symbols found
1>
1>Build FAILED.
If dllmain is your code and you do not need to handle DLL_THREAD_ATTACH and DLL_THREAD_DETACH, then you might want to get rid of your DllMain and move your code to InitInstance/ExitInstance of your CWinApp derived class. Alternatively you might try to play with the linker option /FORCE:MULTIPLE.

link error when change configuration from Debug to Release

Hi
I have project In VC++ 2008
this project compile in debug mode without error
but when I try to build it in release mode I get below linking erorr.
1>Linking...
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __heap_alloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __recalloc already defined in LIBCMT.lib(recalloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __msize already defined in LIBCMT.lib(msize.obj)
1>LIBCMTD.lib(malloc.obj) : error LNK2005: _V6_HeapAlloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in LIBCMT.lib(dbghook.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_pHeaderDefer already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_amblksiz already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_amblksiz already defined in LIBCMT.lib(sbheap.obj)......
how I can fix it?
thanks.
You're mixing VS runtimes - Make sure the "Project Properties/C++/Code Generation/Run-time Library" setting is the same for your project and all libraries you link to.
I had the same problem as you. Reason of this problem is that Linker include a lot of libraries that you dont see (for example you will include windows.h, it includes windef.h and so on...). And because these files are not idiot-proof written (#ifndef is missing) linker will try to #define same thing more times than once - problem.
My solution was setting this field:
Project Properties -> Linker -> Input -> Ignore specific library
to "libcmt.lib"
With this your linker will ignore also in release configuration that problematic library that is included by default and everything should work.. :-)
Have a nice day.. :-)
P.S. If you want to avoid these linker misunderstandings, keep configuring project not in debug or release configuration, but in "All configuration". This option is on left upper corner of project configuration.
You are linking a .obj or .lib file that was compiled in the Debug configuration. Best thing to do is to ensure that file is built in the Release mode as well. Second best is to tell the linker to ignore the request to link to libcmtd.lib. Project + Properties, Linker, Input, Ignore Specific Library = libcmtd.lib. But only do this if you can't get the Release build of a .lib after trying mightily.
you can delete preprocessor definition "DEBUG" to solve your issue
I ran into to similar problem and it was all to do with whether libraries you include build with right end state. If you build a program in release mode and pointed to *.lib files that compiled in debug mode. its going to give you symbol miss match errors. Specially if your program build fines in debug mode or vise versa.
This might not exactly what your problem is but good information for someone who ran into same thing as i did.
You probably have defined all the link information in the "Debug" configuration. Which means you need to either redefine it for "Release" or move it to the "All Configurations" so its shared.