简体   繁体   中英

collect2: error: ld returned 1 exit status graphics.h

I'm using the graphics.h library in Ubuntu 14 And I'm having trouble using this simple code:

#include <graphics.h>

main(){

    int gd = DETECT, gm;
    initgraph(&gd, &gm, "C:\\TC\\BGI");
    putpixel(25, 25, RED);
    closegraph();
    getch();
    return 0;
}

And when I compile it, it gives me this error

collect2: error: ld returned 1 exit status

I don't know what am I doing wrong.

Assuming you've installed all the necessary package,

change: initgraph(&gd, &gm, "C:\\\\\\TC\\\\\\BGI");

to: initgraph(&gd, &gm, NULL);

and compile it with lgraph flag

example: filename is graph.cpp

g++ graph.cpp -o graph -lgraph

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM