Linking to static library
-
I have a static library I have compiled with VS.Net -- the library compiles correctly. However, when I try to link against it I get link errors for multiply-defined symbols such as: CWPDataManager error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::operator+=(char)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D@Z) already defined in MyDateD.lib(MyDate.obj) My library makes use of std::string (as you can see above) and I've put the approriate #ifndef include guards in the library .h file. So, why do I get these link errors when I build my app and link against my libray? Anyone know where my problem is? Thanks, --Dean
-
I have a static library I have compiled with VS.Net -- the library compiles correctly. However, when I try to link against it I get link errors for multiply-defined symbols such as: CWPDataManager error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::operator+=(char)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D@Z) already defined in MyDateD.lib(MyDate.obj) My library makes use of std::string (as you can see above) and I've put the approriate #ifndef include guards in the library .h file. So, why do I get these link errors when I build my app and link against my libray? Anyone know where my problem is? Thanks, --Dean
-
Are there functions in the DLL that returns a pointer or reference to a string object? If so, one solution is to do return by value. Kuphryn
Well, it's not a DLL - it's a static library. I have one function that takes a string by reference (consequently this is where the link errors arise from -- it's the only function that uses string). The function return is void and the string that is passed by reference is modified within the function. The function (inside the library) looks like this:
void CMyClass::format(const char* fmt, string& dest)
{
...
(modify dest)
...
}--Dean
-
Well, it's not a DLL - it's a static library. I have one function that takes a string by reference (consequently this is where the link errors arise from -- it's the only function that uses string). The function return is void and the string that is passed by reference is modified within the function. The function (inside the library) looks like this:
void CMyClass::format(const char* fmt, string& dest)
{
...
(modify dest)
...
}--Dean
-
I have a static library I have compiled with VS.Net -- the library compiles correctly. However, when I try to link against it I get link errors for multiply-defined symbols such as: CWPDataManager error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::operator+=(char)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@D@Z) already defined in MyDateD.lib(MyDate.obj) My library makes use of std::string (as you can see above) and I've put the approriate #ifndef include guards in the library .h file. So, why do I get these link errors when I build my app and link against my libray? Anyone know where my problem is? Thanks, --Dean
That's usually caused by the build settings for the LIB using one form of CRT linking (static or DLL) and the executable using the other. --Mike-- The Internet is a place where absolutely nothing happens. -- Strong Bad 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm