This is the first time I've worked with static libraries and I ran into a little problem, heres the code:
libTest.h
libTest.cppCode:#ifndef __LIBTEST_H__ #define __LIBTEST_H__ #if _MSC_VER > 1000 #pragma once #endif #pragma warning(disable: 4996) #include <string> using namespace::std; class CTest { public: CTest(void); ~CTest(void); int Test(); private: string m_sTest; }; #endif
When I include/link to the libTest library on an application that already includes <string>, I get:Code:#include "libTest.h" CTest::CTest(void) { m_sTest = ""; } CTest::~CTest(void) { } int CTest::Test() { return m_sTest.size(); }
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> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$alloc ator@D@2@@std@@QAE@XZ) already defined in Main.obj
How can I get rid of this problem? My library makes uses of strings/vectors/maps and so on and they all cause 'multiply defined symbol' errors.
Thanks in advance for any help.