Jump to content
  • Advertisement
Sign in to follow this  
AWilson

NEED HELP!! Strange iostream link errors

This topic is 4088 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am compiling with Visual C++ Express Edition and I have incountered a strange iostream/fstream LNK2019 error while compiling source using those header files. I have searched for support but none was found. Below is my error and source... //////////////////////////////////////////////////////////////////////////////////////////////// ------ Build started: Project: test2, Configuration: Debug Win32 ------ Compiling... test2.cpp Linking... test2.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<<char,struct std::char_traits<char> >(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (__imp_??$?6DU?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z) referenced in function _main test2.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_ofstream<char,struct std::char_traits<char> >::open(char const *,int)" (__imp_?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z) referenced in function _main C:\...\test2\Debug\test2.exe : fatal error LNK1120: 2 unresolved externals Build log was saved at "file://c:\...\test2\Debug\BuildLog.htm" test2 - 3 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped //////////////////////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <fstream> using namespace std; int main () { ofstream file222; file222.open ("example.txt"); //error from this file222 << "Writing this to a file.\n"; //error from this file222.close(); return 0; } //////////////////////////////////////////////////////////////////////////////////////////////// I have only used those two header files and created the source from them. I also found that I get those errors from trying to open and write to a file. I have checked all my VC++ directories and am not ignoring them. I have no other clue what to do and am in need of support. I would really appreciate some help. [Edited by - AWilson on May 10, 2007 5:44:56 PM]

Share this post


Link to post
Share on other sites
Advertisement
are you using MS Platform SDK's version of the STL or some other STL version? The one that comes with microsoft doesn't use the __declspec(dllimport) keyword. if you are using another STL (like what's out there? i dunno... STLPort?), don't forget to include and link whatever lib files they have that are necessary.

Share this post


Link to post
Share on other sites
I've seen weird errors like this when helping a friend set up VC2005 express.

From memory the order of the include directories is very significant, if you've just installed the platform SDK this is likely to be the culprit. If possible look at the ordering of the include directories on a clean machine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!