Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error message stating an external symbol is unrsolved. Not sure how to proceed?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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;

}

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading