Problem linking stl strings
-
Hi, I'm having a bit of a problem linking my application using stl. I have a library that uses the stl string. This is also used in a header file used by the application that links to the library. I get a bunch of linker errors LNK4006 saying that std::basic_string is already defined in the lib. Can anyone shed any light on what I need to do to overcome this?
-
Hi, I'm having a bit of a problem linking my application using stl. I have a library that uses the stl string. This is also used in a header file used by the application that links to the library. I get a bunch of linker errors LNK4006 saying that std::basic_string is already defined in the lib. Can anyone shed any light on what I need to do to overcome this?
The problem is that the std:basic_string object that you have is declared twice between your lib file and your application. Is there a variable or a typedef in your project that is the same as a variable in the lib that you are using? Possibly in the header file that you mentioned. Did you write the LIB?
-
The problem is that the std:basic_string object that you have is declared twice between your lib file and your application. Is there a variable or a typedef in your project that is the same as a variable in the lib that you are using? Possibly in the header file that you mentioned. Did you write the LIB?
Yep, I wrote it. The class Token is declared in Token.h and is implemented in the lib, and used by the application calling the lib. class Token { std::string tokenText; public: ... bool operator==(const std::string& aTokenText); ... }; It worked ok, until I included token.h in the calling app. There are no other typedefs in the header and it has include guards.
-
Yep, I wrote it. The class Token is declared in Token.h and is implemented in the lib, and used by the application calling the lib. class Token { std::string tokenText; public: ... bool operator==(const std::string& aTokenText); ... }; It worked ok, until I included token.h in the calling app. There are no other typedefs in the header and it has include guards.
If you comment out the one member tokenText in your class, do you still get the error?
-
If you comment out the one member tokenText in your class, do you still get the error?
-
Yep, I still get the linking error, even after I remove all of the references to string. This is somewhat strange.
I would have to see the whole header file before I could help you any more, maybe you could post it, or email it to me?
-
Hi, I'm having a bit of a problem linking my application using stl. I have a library that uses the stl string. This is also used in a header file used by the application that links to the library. I get a bunch of linker errors LNK4006 saying that std::basic_string is already defined in the lib. Can anyone shed any light on what I need to do to overcome this?
-
Hi, I'm having a bit of a problem linking my application using stl. I have a library that uses the stl string. This is also used in a header file used by the application that links to the library. I get a bunch of linker errors LNK4006 saying that std::basic_string is already defined in the lib. Can anyone shed any light on what I need to do to overcome this?
-
Aaaargh... Thanks for your help guys. I had a break and came back at it with a fresh look. It turns out that the lib was being compiled with debug single threaded and... you guessed it, the app was compiled with debug multi threaded. Doh!
It was still fun racking my brain.:omg: