Communication error fstream in g ++ with -std = gnu ++ 0x

I have an application built with the -std = gnu ++ 0x option in tdm-mingw g ++ 4.4.0 on windows.

It uses an outstream object, and when I build it, it gives the following binding 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 works correctly when using the standard default standard standard.

This is the only error, and trying to associate with -lstdC ++ does not help. Has anyone experienced this before? Can I get any suggestions?

Edit: I create an 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 compiles in order, but is not bound.

+3
source share
1 answer

I would suggest that you have code like this:

string fname = "foo.txt";
ifstream ifs( fname );

Try changing it to:

ifstream ifs( fname.c_str() );

, , , - , . , , .

+3

Source: https://habr.com/ru/post/1713228/


All Articles