I'm have an application built with the -std=gnu++0x parameter in tdm-mingw g++ 4.4.0 on windows.
It is using an ofstream object and when I build, it gives the following linking error:
c:\opt\Noddler/main_func.cpp:43: undefined reference to `std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(std::string const&, std::_Ios_Openmode)'
It builds properly when using the default older standard.
This is the only error, and trying to link with -lstdc++ doesn't help. Has someone experienced this before? Can I get any suggestions?
Edit: I'm creating an ofstream object like this:
std::string filename = string("noddler\\") + callobj.get_ucid() + "_" + callobj.gram_counter() + ".grxml";
ofstream grxml_file(string("C:\\CWorld\\Server\\Grammar\\") + filename);
...
grxml_file.close();
It is getting compiled fine, but not getting linked.
I would guess that you have some code like this:
string fname = "foo.txt";
ifstream ifs( fname );
Try changing it to:
ifstream ifs( fname.c_str() );
This could happen if the header files you are using are somewhat out of whack with the libraries you are linking to. And if this doesn't work, post the code that causes the problem.