Dll Problem
-
Hi, i want to create a dll to call some functions i was using in one of my progs.. the linker gives me following errors: Linking... nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in Test.obj nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in Test.obj; second definition ignored Creating library Debug/Test.lib and object Debug/Test.exp nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc Debug/Test.dll : fatal error LNK1120: 3 unresolved externals Any ideas ?
"Just looking for loopholes." W. C. Fields
American actor, 1880-1946, explaining why he was reading the Bible on his deathbed. -
Hi, i want to create a dll to call some functions i was using in one of my progs.. the linker gives me following errors: Linking... nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in Test.obj nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in Test.obj; second definition ignored Creating library Debug/Test.lib and object Debug/Test.exp nafxcwd.lib(timecore.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol __mbctype nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv nafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc Debug/Test.dll : fatal error LNK1120: 3 unresolved externals Any ideas ?
"Just looking for loopholes." W. C. Fields
American actor, 1880-1946, explaining why he was reading the Bible on his deathbed.By looking at the included libraries, it seems that your DLL is using MFC, linked statically. You cannot, and I repeat, cannot use DllMain as the DLL entry point when using MFC. Instead, I suggest you create a whole new DLL project, this time by using the MFC DLL Wizard which comes with Visual Studio. It creates a skeleton project for you, indicating places where you should add code by inserting comments. As for the other errors, it seems that your linker input libraries are missing something. For a general rule of thumb, create a new project and copy/paste relevant code over the new skeleton. The reason why you cannot use DllMain is because MFC already offers this function in it's core libraries. This is, by Microsoft's words: "Behaviour by design". MFC's DllMain will query for an external
CWinApp
object, which is exported by the main code module of your project (Usually defined asC<Project name>App theApp
). It will then call the InitInstance function of your class to start the DLL's execution. So, all in all, create a new project by using the MFC DLL Wizard. This will solve 99% of the problems you listed, although moving the code from the current project into the new skeleton project may be quite difficult. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.