Sign in to follow this  
AWilson

NEED HELP!! Strange iostream link errors

Recommended Posts

AWilson    122
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
yadango    567
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
XXX_Andrew_XXX    340
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this