Skip to main content Skip to navigation

nolinkersymbol


There are occasional reports of error such as

warning: can't find linker symbol for virtual table for 'std::basic_filebuf<char, std::char_traits<char> >' value
warning: found 'fhandler_dev_zero::mmap(char**, unsigned long, int, int, long)' instead

In my case it turned out to be because of an ofstream that was in scope but was only declared later on in the code.

The trick was to make its declaration the first item in scope:

Original

....
ofstream fout("test2.txt"); //opening an output stream for file test.txt
if(fout.is_open()) {
...

Fixed

....
{

ofstream fout("test2.txt"); //opening an output stream for file test.txt

if(fout.is_open()) {

...

}