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
Related
I have a DLL project I am compiling on Visual Studio 2022 that is importing a lib from created by another project. When I try to compile this code, I receive this: nafxcw.lib(dllmodul.obj) : error LNK2005: DllMain already defined in LIBCMT.lib(dll_dllmain_stub.obj). I have looked everywhere, but I cannot seem to find a solution that works.
I have tried adding these libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib to the ignore libraries list.
I tried adding extern "C" { int __afxForceUSRDLL; } to the DLLMain in the file from the imported library that has the redefined DLLMain, but this leads to an error saying that __afxForceUSRDLL has been defined twice.
Any and all help would be extremely appreciated.
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
It has been about a year since I wrote any .dll plugins that use LibCurl, but I decided to start on another one tonight. Unfortunately, I have been combating the same linker errors for almost 4 hours now, and I am completely lost.
I am statically building LibCurl, and it appears to be fine for the most part, except I am getting the following linker errors.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined in memoverride.obj
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _realloc already defined in memoverride.obj
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in memoverride.obj
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in memoverride.obj
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __strdup already defined in memoverride.obj
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __malloc_crt already defined in memoverride.obj
I have tried...
1) Reorganizing my included libs due to MSDN saying LNK2005 was caused by this.
2) Rebuilding the LibCurl lib through MSVC Application, then through the Command-Line tool.
3) Excluding the libs that are causing issues.
and a bunch of other things that I cannot even remember now. Can anyone help me out with some information as to how I can solve these?
Problem was my .dll was /MT while the libcurl was /MD. Also, I had initially blocked "libcmt", so when I was switching libcurl to /MT, it was spewing errors.
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.
Here is My Scenario.
I have an Existing Solution in visualstudio which contains 15 projects.
in some project i need to use managed c++ extensions. So first i have a workaround for sample solution contains 4 projects in those i have maintained dependencies b/w them.
and my solution is builded also.
I apply the same procedure to existing solution by adding extra project which contains managed code.so that i enable CLR in calling project(from where i call new added project methods from existing ex:demoproj) as well as project which contains main().and change the runtime from /mtd(existing one contains /mtd) to /mdd.
when i build the demoproj it builds success fully. But when i building project which contains main() it gives lot of errors like
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)
LIBCMTD.lib(fclose.obj) : error LNK2005: _fclose already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(printf.obj) : error LNK2005: _printf already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(mbstowcs.obj) : error LNK2005: _mbstowcs already defined in MSVCRTD.lib(MSVCR80D.dll)
I found this is happend because of using /clr option i think any idea???
But this case is not happend for my test solution.How to resolve this
Any help is greatly appreciated
All the dlls you link to using import libraries must have the same setting as the application for how you link to the runtime library. The errors are showing that you are mixing use of the runtime as a .dll (MSVCRTD) and as a .lib (LIBCMTD).