# NEED HELP!! Strange iostream link errors

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

## 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 on other sites
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 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 on other sites

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