Home > Back-end >  Error message stating an external symbol is unrsolved. Not sure how to proceed?
Error message stating an external symbol is unrsolved. Not sure how to proceed?

Time:07-08

I'm receiving this error when i try to compile Please ask if you'd like me to post other functions written? I can't pinpoint exactly where the error is coming from.

Error LNK2019 unresolved external symbol "class std::basic_ofstream<char,struct std::char_traits > & __cdecl operator<<(class std::basic_ofstream<char,struct std::char_traits > &,class Pixel const &)" (??6@YAAEAV?$basic_ofstream@DU?$char_traits@D@std@@@std@@AEAV01@AEBVPixel@@@Z) referenced in function "void __cdecl saveToPPM(class Fractal const &,char const *)" (?saveToPPM@@YAXAEBVFractal@@PEBD@Z)

The error is on line 1 of Fractal.obj

void saveToPPM(const Fractal& f, const char* fn) {
    cout << "> Saving Fractal Object to ASCII File..." << endl;

    ofstream outfile(fn);

    outfile << "P6" << '\n'
        << "# Sample Comment" << '\n'
        << f.rows << ' ' << f.cols << '\n'
        << f.maxIter << '\n';

    for (int i = 0; i < f.rows; i  )
    {
        for (int j = 0; j < f.cols; j  ) {
            outfile << f.grid[i][j] << " ";
        }

        outfile << endl;
    }
}

ofstream& operator<<(ofstream& os, Pixel& p) {
    
    os << p["red"] << " " << p["green"] << " " << p["blue"] << " ";
    
    return os;

}

CodePudding user response:

This could be a problem with what os is writing. It looks like g[i][j] is a Pixel object and the error is happening when you try to write an object to file.

  •  Tags:  
  • c
  • Related