Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Dll Problem

Dll Problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bernhard
    wrote on last edited by
    #1

    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.

    A 1 Reply Last reply
    0
    • B Bernhard

      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.

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      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 as C<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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups