Linker errors in VC++ 2005
I have writen some code on top of the raknet networking library to add an event system, I'll call this "NetworkEngine" from now on. This code is done and works fine when I compile it as a console application.
I want to use this code in two ways: from a C++ application, and as a plugin in the A6 game engine. So I came up with this idea:
Build the NetworkEngine as a static library (.lib).
For my C++ app: simply link the NetworkEngine library and use the classes.
For the A6 plugin: create a new C++ dll-project that links an engine library (this is required) and the NetworkEngine.lib.
I haven't tried linking the library in a c++ app, but I'm now creating the A6 plugin and am running into some problems.
When I try to build the plugin project, I get a linker error: can't find libc.lib. The A6 manual says the following about building plugins in VC++ 2005:
So the first thing I tried is this:
When using VC++ 2005, you also need to tell the linker not to use the libc.lib that was abandoned by Microsoft. Thus, ignore the specific library libc.lib in the project properties for Debug and Release, and add libcmt.lib to the Linkers Additional Dependencies
General > Configuration Type: Static Library (.lib)
C / C++ > Code Generation > Runtime Library: Multi-threaded Debug (/MTd)
Librarian > General > Additional Dependencies: RakNetLibStaticDebug.lib (needed because I use RakNet)
Librarian > General > Link Library Dependencies: Yes (Otherwise I'd have to link to RakNet in the project that uses this NetworkEngine library)
General > Configuration Type: Dynamic Library (.dll)
C / C++ > Code Generation > Runtime Library: Multi-threaded Debug DLL (/MDd)
Linker > Input > Additional Dependencies: "Network Engine.lib" adll.lib libcmt.lib // Network Engine.lib is my own library, adll.lib is the A6 engine library that has to be linked and libcmt.lib is what the manual tells me to link.
Linker > Input > Ignore Specific Library: libc.lib
The crazy thing is, that when I don't use any objects from my NetworkEngine library, it compiles and links fine, and I can use the plugin (without any usefull functions, though) in A6. When I add this line:
I get a whole bunch of linker errors. The above line works when I put it in the NetworkEngine project and compile it as a console application. When I link to the NetworkEngine library and put the above line in my Plugin project, I get linker errors like these:
NetworkEngine NE(10, 10, 60000, 5); // Create an instance of class NetworkEngine, called NE.
When I use Ignore Specific Library AND /NODEFAULTLIB:library for all the libs that are causing problems (libc.lib MSVCRTD.lib libcpmtd.lib LIBCMTD.lib MSVCRTD.lib libcpmtd.lib), I get different linker errors:
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcmt.lib(typinfo.obj)
libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP80D.dll)
As you can see now it seems like my own lib has problems. It can't find std::cout.. I guess it is in one of those libraries I excluded..
Network Engine.lib(NetworkEngine.obj) : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > std::cout" (?cout@std@@3V?$basic_ostream@DU?$char_traits@D@st d@@@1@A)
This is driving me crazy.. Any help is greatly appreciated!