Compiling a static lib in VC++ 2005 express

Started by
10 comments, last by Endar 17 years, 9 months ago
I'm attempting to set up a project that will do nothing except compile my engine code to a library, so I can have other projects to use that library to make everything easier, and so I can start using my engine as an engine. I just created the new project and followed the "Walkthrough: Creating and Using a Static Library" article on MSDN. My problem is that I just pressed compile, and I got a huge amount of warnings and a couple of errors. Why? I mean, if I'm not getting these errors when I compile the whole thing as an application (the only difference being I have a source file with a 'main' being compiled as well), why should I be getting them now? Has this happened to anyone else? Also, I'm not telling the compiler to ignore any warnings or errors in the 'main' source file. Edit:: I'm also getting "'CreateFontW' : cannot convert parameter 14 from 'const char *' to 'LPCWSTR'" errors where I never got them before. Am I not including something that I should be? I wasn't including anything in the 'main' source file. Not windows.h, not stdio.h, nothing except the main include (the file which includes all the headers in the engine).
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Advertisement
In your settings go to your project properties and on the Configuration Properties -> General page, change the "Character Set" setting from "Use Unicode Character Set" to "Use Multi-Byte Character Set".
This will at least take care of the "cannot convert parameter 14 from 'const char *' to 'LPCWSTR'"" type errors.
Then come back and post what errors and warnings you're still getting after you've done that. ;)
What errors are you getting? Are they compile or linker errors?
Evil Steve: They were all compile errors and compile warnings.

Red Ant: Thanks for that, now the errors are gone and I've just got a whole bunch of warnings. Does this mean that whenever I create a new project and want to use normal characters with windows functions, I'm going to have to change that? Isn't that a little silly?

Anyway, the warnings that I get now are mostly "conversion from 'size_t' to 'int'" or to 'unsigned int' in one form or another (assignment, arguments, etc).

Hmmm, now here's some I've never seen before:
warning C4311: 'type cast' : pointer truncation from 'echo::core::CEngine *const ' to 'long'warning C4312: 'type cast' : conversion from 'LONG' to 'echo::core::CEngine *' of greater size

and the guilty line of code is:
// store pointer to this CEngine object for later retrieval in the WndProc functionSetWindowLong(m_hwnd, GWL_USERDATA, (long)this);

Which, I suppose is fair enough, but I wasn't having any problems with this before, and I was fequently using that pointer.

I then get a bunch of "conversion from 'WPARAM' to 'unsigned int'" warnings. And then the rest are "conversion from 'size_t' to 'unsigned int'" or 'int' warnings.

Isn't this a little strange? I mean you wouldn't think that moving source code from one project to another would actually create errors, so I must be missing some project options.

The project that all this source was previously in was imported from a VC++ 6 project. Are there some project settings that are implicitly set when a project is imported from a previous version of VS?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
In your older (converted-from-VC6) project, the compiler was likely not set to detect potential 64-bit compilation issues. If you are not planning on targeting a 64-bit platform, you can safely ignore or disable these warnings (the setting is under C++->General in your project settings). Under 64-bit platforms, pointers are 64 bits in size, while 'long' usually remains 32-bit for backwards compatibility. size_t is also 64 bit on these platforms.
Thanks. I also found out that I had to disable it on both the Debug and Release versions.

Another question: Why would be lib file end up being 7 meg? I thought that maybe it was because I was compiling in Debug, so I changed to Release, and that ended up as 12 meg!

Should I have set some particular optimization settings?

I am doing some things that could cause code bloat: I have a bunch of classes that are generated at compile time, but I was using them in my previous exectuable (before I tried compiling to a libary) and the size of that exectuable (in debug mode) is 1.75 meg.

What am I doing wrong?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
I've added the project that compiles the library to the current solution so it should compile that first (hopefully) and I now have a whole bunch of link errors:

1>------ Build started: Project: test, Configuration: Debug Win32 ------2>------ Build started: Project: Echo, Configuration: Debug Win32 ------2>Compiling...1>Linking...1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > & (__cdecl*)(class std::basic_ostream<char,struct std::char_traits<char> > &))" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" (?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "bool __cdecl std::operator==<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$?8DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@0@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(int)" (?width@ios_base@std@@QAEHH@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBEHXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) already defined in libcpmtd.lib(uncaught.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl std::operator+<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?HDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@ABV10@PBD@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in libcpmtd.lib(xlock.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in libcpmtd.lib(xlock.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) already defined in libcpmtd.lib(stdthrow.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(char const *,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBDI@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::_Container_base::~_Container_base(void)" (??1_Container_base@std@@QAE@XZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "bool __cdecl std::operator<<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$?MDU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@0@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: void __thiscall std::_Container_base::_Orphan_all(void)const " (?_Orphan_all@_Container_base@std@@QBEXXZ) already defined in test.obj2>CDebugConsole.cpp1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::_Container_base::_Container_base(void)" (??0_Container_base@std@@QAE@XZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::fail(void)const " (?fail@ios_base@std@@QBE_NXZ) already defined in test.obj1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _vsprintf already defined in LIBCMTD.lib(vsprintf.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strftime already defined in LIBCMTD.lib(strftime.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __localtime64 already defined in LIBCMTD.lib(loctim64.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __time64 already defined in LIBCMTD.lib(time64.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _ftell already defined in LIBCMTD.lib(ftell.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fseek already defined in LIBCMTD.lib(fseek.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fopen already defined in LIBCMTD.lib(fopen.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fgets already defined in LIBCMTD.lib(fgets.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __wassert already defined in LIBCMTD.lib(wassert.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: bool __thiscall type_info::operator==(class type_info const &)const " (??8type_info@@QBE_NABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: char const * __thiscall type_info::raw_name(void)const " (?raw_name@type_info@@QBEPBDXZ) already defined in LIBCMTD.lib(typinfo.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _isalpha already defined in LIBCMTD.lib(_ctype.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _isspace already defined in LIBCMTD.lib(_ctype.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _isprint already defined in LIBCMTD.lib(_ctype.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __CrtDbgReportW already defined in LIBCMTD.lib(dbgrptw.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMTD.lib(stdexcpt.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: __thiscall std::bad_cast::bad_cast(char const *)" (??0bad_cast@std@@QAE@PBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: virtual __thiscall std::bad_cast::~bad_cast(void)" (??1bad_cast@std@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: __thiscall std::bad_cast::bad_cast(class std::bad_cast const &)" (??0bad_cast@std@@QAE@ABV01@@Z) already defined in LIBCMTD.lib(stdexcpt.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fclose already defined in LIBCMTD.lib(fclose.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _fread already defined in LIBCMTD.lib(fread.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _isupper already defined in LIBCMTD.lib(_ctype.obj)1>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 LIBCMTD.lib(typinfo.obj)1>MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::compare(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?compare@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEHABV12@@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::append(unsigned int,char)" (?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ID@Z) already defined in libcpmtd.lib(cerr.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "protected: char * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Myptr(void)" (?_Myptr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEPADXZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::_String_iterator<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::begin(void)" (?begin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE?AV?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ) already defined in libcpmtd.lib(cerr.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(unsigned int,char)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ID@Z) already defined in libcpmtd.lib(cerr.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(unsigned int,char)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ID@Z) already defined in libcpmtd.lib(cerr.obj)1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::_String_val<char,class std::allocator<char> >::~_String_val<char,class std::allocator<char> >(void)" (??1?$_String_val@DV?$allocator@D@std@@@std@@QAE@XZ) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "protected: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Tidy(bool,unsigned int)" (?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEX_NI@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "protected: __thiscall std::_String_val<char,class std::allocator<char> >::_String_val<char,class std::allocator<char> >(class std::allocator<char>)" (??0?$_String_val@DV?$allocator@D@std@@@std@@IAE@V?$allocator@D@1@@Z) already defined in test.obj1>msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall std::allocator<char>::allocator<char>(void)" (??0?$allocator@D@std@@QAE@XZ) already defined in test.obj1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _memmove_s already defined in LIBCMTD.lib(memmove_s.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _tolower already defined in LIBCMTD.lib(tolower.obj)1>MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _memmove already defined in LIBCMTD.lib(memmove.obj)1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library1>test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall echo::core::CDebugConsole::addObjectFunction<void,class echo::scene::ISkeletalModel,float,float>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class echo::scene::ISkeletalModel *,void (__thiscall echo::scene::ISkeletalModel::*)(float,float))" (??$addObjectFunction@XVISkeletalModel@scene@echo@@MM@CDebugConsole@core@echo@@QAE_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVISkeletalModel@scene@2@P8562@AEXMM@Z@Z) referenced in function _main1>test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall echo::core::CDebugConsole::addObjectFunction<void,class echo::scene::ISkeletalModel,float>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class echo::scene::ISkeletalModel *,void (__thiscall echo::scene::ISkeletalModel::*)(float))" (??$addObjectFunction@XVISkeletalModel@scene@echo@@M@CDebugConsole@core@echo@@QAE_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVISkeletalModel@scene@2@P8562@AEXM@Z@Z) referenced in function _main1>test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall echo::core::CDebugConsole::addObjectFunction<void,class echo::scene::ISkeletalModel,float,float,float>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class echo::scene::ISkeletalModel *,void (__thiscall echo::scene::ISkeletalModel::*)(float,float,float))" (??$addObjectFunction@XVISkeletalModel@scene@echo@@MMM@CDebugConsole@core@echo@@QAE_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVISkeletalModel@scene@2@P8562@AEXMMM@Z@Z) referenced in function _main1>test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall echo::core::CDebugConsole::addObjectFunction<void,class echo::scene::ISkeletalModel,bool>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class echo::scene::ISkeletalModel *,void (__thiscall echo::scene::ISkeletalModel::*)(bool))" (??$addObjectFunction@XVISkeletalModel@scene@echo@@_N@CDebugConsole@core@echo@@QAE_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVISkeletalModel@scene@2@P8562@AEX_N@Z@Z) referenced in function _main1>test.obj : error LNK2019: unresolved external symbol "public: bool __thiscall echo::core::CDebugConsole::addFunction<void,bool>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,void (__cdecl*)(bool))" (??$addFunction@X_N@CDebugConsole@core@echo@@QAE_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@P6AX_N@Z@Z) referenced in function _main1>.\Debug/test.exe : fatal error LNK1120: 5 unresolved externals1>Build log was saved at "file://c:\Documents and Settings\Naim\My Documents\Programming\everything\engine\Debug\BuildLog.htm"1>test - 87 error(s), 1 warning(s)2>CVideoDriver.cpp2>Generating Code...2>Compiling...2>CDebugConsoleEventReceiver.cpp2>CEngine.cpp2>TextureLoader.cpp2>CAnimatedMeshMD2.cpp2>CMD5Model.cpp2>CSceneGraph.cpp2>IAnimatedMesh.cpp2>ISkeletalModel.cpp2>Generating Code...2>Creating library...2>Build log was saved at "file://c:\Documents and Settings\Naim\My Documents\Programming\everything\Echo\Echo\Debug\BuildLog.htm"2>Echo - 0 error(s), 0 warning(s)========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


It looks like it compiles the library with no problems, but has problems finding the library to use.

I have this at the very beginning of my code:
#include "C:\\Documents and Settings\\Naim\\My Documents\\Programming\\everything\\Echo\\Echo\\core\\echo.h"#pragma comment(lib, "C:\\Documents and Settings\\Naim\\My Documents\\Programming\\everything\\Echo\\debug\\Echo.lib")

And it doesn't complain that it can't find the lib file, so I assume that it has found it.

Am I going about this the wrong way, or did I simply forget something?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
The problem is the version of the CRT. It should match (DLL or static) for all libs.

found under project/properties/C++/Code Generation.
Holy crap I started a blog - http://unobvious.typepad.com/
Okay, but should I use the debug version for the debug version of my project? Or should I just keep it with the normal version of the CRT? Or does that just let me step through the assembly, or whatever else they have for a function in the CRT?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Normaly, people are linking debug CRT libraries in debug builds and release CRT in release builds. Normaly...
Ofcourse, you can link what ever you want, unless, ofcourse, you are using some functions that only exists in debug library.

About the size of your library... Are you linking the library dependencies in your library project? The setting can be found in project properties (Configuration Properties, Librarian, General; option title is "Link Library Dependencies")? Personaly, i'd recomend you to turn this thing off.
Let's say you are linking in the static multithreaded CRT libraries (debug and release) into your library project. Then, you make a new project that uses your own library but wants to use the shared multithreaded CRT libraries... Whenever you link this project - there will be a bunch of linker errors.
That is why, i never link the library dependecies into my static library projects - i let the projects that will use my library decide what CRT (and other libs) to use.

This topic is closed to new replies.

Advertisement