collect2:错误:ld 返回 1 个退出状态图形

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

本文关键字:退出 状态 图形 状态图 错误 ld 返回 collect2      更新时间:2023-10-16

我在 Ubuntu 14 中使用 graphics.h 库我在使用这个简单的代码时遇到问题:

#include <graphics.h>
main(){
    int gd = DETECT, gm;
    initgraph(&gd, &gm, "C:\TC\BGI");
    putpixel(25, 25, RED);
    closegraph();
    getch();
    return 0;
}

当我编译它时,它给了我这个错误

collect2:错误:ld 返回 1 个退出状态

我不知道我做错了什么。

假设您已经安装了所有必要的软件包,

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

收件人: initgraph(&gd, &gm, NULL);

并用 lgraph 标志编译它

示例:文件名为图形.cpp

g++ graph.cpp -o graph -lgraph