Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STL in a Static Library Project - Linking Problem

Status
Not open for further replies.

gumug

Programmer
Apr 13, 2004
1
US
Hi,

I have a VC++ project that is composed of 2 sub-projects, a win32 app and a win32 static library.

I'm trying to use the STL stack. I can make the code compile & link in the main project, but the same 'stack' code won't link properly when used in the static library [LNK2001: unresolved external symbol...].

I have tried adding the lib file through options in both projects. I also tried adding the library to the project itself.

I think I'm probably missing something obvious, but I can't seem to figure it out. Any help would be appreciated.

Thanks,
kg
 
If you're implementing templates of your own make sure the methods are inline.


/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
I have the same problem, but I am not creating any templates of my own. Only using the stl containers. All the link errors show up as missing from the library when the library is used in the main applicaton, but the library builds OK when built alone.

 
Then the obvious question is : Are you sure youre linking the lib into the app?

/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
Yes the library is trying to link, but I get the following two errors, many many times.

warning LNK4049: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported

warning LNK4217: locally defined symbol ??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ (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)) imported in function "class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > & __cdecl std::eek:perator<<<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >(class std::basic_ostream<unsigned short,struct std::char_traits<unsigned short> > &,class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (??$?6GU?$char_traits@G@std@@V?$allocator@G@1@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z)

It appears that the STL being used in the application and the library are conflicting or something else.

thanks for the help
mark
 
>I get the following two errors
>warning LNK4049
>warning LNK4217

warning != error

/Per

&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top