Thread: DLL compiling question

  1. #1
    Registered User Noose's Avatar
    Join Date
    Jul 2003
    Posts
    11

    DLL compiling question

    Hope someone can figure this out for me or point me in the right direction cause this is a lingering problem I cant seem to figure out.
    I have a solution (workspace) that contains a bunch of different projects (2 static libs, one dll, and win32 app currently), when first building the dll I found myself having to use some of files from the win32 project in the dll project.
    Ex.
    win32 project contains FileA.h and FileA.cpp. The DLL #include'd FileA.h so I had to move FileA.cpp into the DLL project also, so the DLL build would create the FileA.obj and wouldnt complain.
    Got tired of doing that for FileB.h (FileB.cpp), FileC.h (FileC.cpp), etc. (all math related) so built them into what is the second static lib now the DLL project #include's file header and I link the lib. no problem.
    Well, the DLL project begins needing a bunch of other misc files. So decide to make another static lib (which will be the third, to avoid having to move a good number of .h/.cpp files everytime a new project requires them) only this time I get tons of errors that make no sense to me. The static libs seem to build correctly, but now the DLL project (after setting dependencie on new static lib) I get this

    Generating Code...
    Linking...
    libcpmtd.lib(xmutex.obj) : error LNK2005: "public: void __thiscall std::_Mutex::_Lock(void)" (?_Lock@_Mutex@std@@QAEXXZ) already defined in BuildLib.lib(DebugConsole.obj)
    libcpmtd.lib(xmutex.obj) : error LNK2005: "public: void __thiscall std::_Mutex::_Unlock(void)" (?_Unlock@_Mutex@std@@QAEXXZ) already defined in BuildLib.lib(DebugConsole.obj)
    libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in BuildLib.lib(DebugConsole.obj)
    libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in BuildLib.lib(DebugConsole.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __exitflag already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __wenviron already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: ___initenv already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __environ already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: ___wargv already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: ___argv already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: ___argc already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __winminor already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __winmajor already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __winver already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __osver already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __osplatform already defined in LIBCMTD.lib(crt0dat.obj)
    LIBCD.lib(crt0dat.obj) : error LNK2005: __umaskval already defined in LIBCMTD.lib(crt0dat.obj)
    libcpmtd.lib(xmutex.obj) : warning LNK4006: "public: void __thiscall std::_Mutex::_Lock(void)" (?_Lock@_Mutex@std@@QAEXXZ) already defined in BuildLib.lib(DebugConsole.obj); second definition ignored
    libcpmtd.lib(xmutex.obj) : warning LNK4006: "public: void __thiscall std::_Mutex::_Unlock(void)" (?_Unlock@_Mutex@std@@QAEXXZ) already defined in BuildLib.lib(DebugConsole.obj); second definition ignored
    libcpmtd.lib(xlock.obj) : warning LNK4006: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in BuildLib.lib(DebugConsole.obj); second definition ignored
    libcpmtd.lib(xlock.obj) : warning LNK4006: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in BuildLib.lib(DebugConsole.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __cinit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: _exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __cexit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __c_exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __exitflag already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __wenviron already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: ___initenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __environ already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: ___wargv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argc already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __winminor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __winmajor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __winver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __osver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __osplatform already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    LIBCD.lib(crt0dat.obj) : warning LNK4006: __umaskval already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
    Creating library Debug/DLLProject.lib and object Debug/DLLProject.exp
    LINK : warning LNK4098: defaultlib 'LIBCD' conflicts with use of other libs; use /NODEFAULTLIB:library
    Debug/DLLProject.dll : fatal error LNK1169: one or more multiply defined symbols found

    as I reduce the number of files that get built into the static lib this list reduces to about 5 errors and 5 warnings, but instead of saying
    defined in BuildLib.lib(DebugConsole.obj)
    it will just sub in the another of my file names in place of DebugConsole.obj
    Can anyone tell me why all three static libs build correctly but this is the only one that gives me this problems when used in the DLL project?
    Im using C++ on VC++.Net 2003

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>LINK : warning LNK4098: defaultlib 'LIBCD' conflicts with use of other libs; use /NODEFAULTLIB:library

    try adding...

    /NODEFAULTLIB:"LIBCMT.lib"

    when linking

    In MSVC .NET open solution properties -> linker -> Input.
    Add the libs to 'ignore specific library' seperated by commas. (probably LIBCMT.lib,LIBC.lib,LIBCD.lib)


    >>The DLL #include'd FileA.h so I had to move FileA.cpp into the DLL project also,

    why did you not just add the files to the project using their current path?

    ie
    #include "c:\library\FileA.h"
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    >why did you not just add the files to the project using their current path?
    A perfectly reasonable solution, but if you have a lot of includes from one path, you can always add /I C:\library to your command line as well.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. dll question
    By keeper in forum C++ Programming
    Replies: 1
    Last Post: 06-04-2006, 09:44 AM
  3. DLL file question
    By xixpsychoxix in forum C Programming
    Replies: 30
    Last Post: 03-08-2006, 09:54 PM
  4. dll question
    By Rune Hunter in forum C# Programming
    Replies: 3
    Last Post: 04-01-2005, 02:56 PM
  5. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM