【问题标题】:collect2: error: ld returned 1 exit status graphics.hcollect2:错误:ld 返回 1 退出状态 graphics.h
【发布时间】:2016-02-15 01:08:29
【问题描述】:

我在 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 个退出状态

我不知道我做错了什么。

【问题讨论】:

  • 你忘记链接库了吗? (gcc 中的 -L 和 -l 选项)
  • 不,我没有忘记我在这里遇到了很多麻烦

标签: c++


【解决方案1】:

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

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

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

并用 lgraph 标志编译它

例子:文件名是graph.cpp

g++ graph.cpp -o graph -lgraph

【讨论】:

  • 谢谢你,好人,但它不起作用我已经尝试过了。我还是一样
  • 你确定你已经安装了必要的库吗?看看这个 (askubuntu.com/questions/525051/…)
  • 是的,我已经安装了那个库,但是还是不行,谢谢你的帮助。
  • 你可能无法链接库,如何明确链接它试试这个g++ graph.cpp -o graph /path/to/libgraph.a
猜你喜欢
  • 2014-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-12
  • 1970-01-01
  • 2011-08-26
  • 1970-01-01
  • 2015-02-19
相关资源
最近更新 更多