c++ - 找不到 -lbgi 和 ld 返回 1 个退出状态错误

标签 c++ mingw project dev-c++ bgi

我正在尝试使用 dev c++ 在 c++ 图形中绘制线条,这是代码

// C++ Implementation for drawing line 
#include <graphics.h> 

// driver code 
int main() 
{ 
    // gm is Graphics mode which is a computer display 
    // mode that generates image using pixels. 
    // DETECT is a macro defined in "graphics.h" header file 
    int gd = DETECT, gm; 

    // initgraph initializes the graphics system 
    // by loading a graphics driver from disk 
    initgraph(&gd, &gm, ""); 

    // line for x1, y1, x2, y2 
    line(150, 150, 450, 150); 

    // line for x1, y1, x2, y2 
    line(150, 200, 450, 200); 

    // line for x1, y1, x2, y2 
    line(150, 250, 450, 250); 

    getch(); 

    // closegraph function closes the graphics 
    // mode and deallocates all memory allocated 
    // by graphics system . 
    closegraph(); 
} 

但在编译过程中一次又一次地出现以下错误,我不确定如何解决这些问题。

C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/libbgi.a when searching for -lbgi
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../lib/libbgi.a when searching for -lbgi
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../libbgi.a when searching for -lbgi
C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lbgi
collect2.exe: error: ld returned 1 exit status

C:\Program Files (x86)\Dev-Cpp\Makefile.win:25: recipe for target 'Project1.exe' failed
mingw32-make.exe: *** [Project1.exe] Error 1

错误截图

我试过将这些包含在项目参数链接器选项卡中

  • -lbgi
  • -lgdi32
  • -lcomdlg32
  • -luuid
  • -loleaut32
  • -lole32

此外,我在 devc++ 文件夹中有 graphics.h 库。但不确定为什么会不断弹出此错误。请有人指出我的错误。

最佳答案

将 TDM-GCC 4.9.2 64 位版本更改为 TDM-GCC 4.9.2 32 位版本

关于c++ - 找不到 -lbgi 和 ld 返回 1 个退出状态错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56099442/

相关文章:

c++ - `xvalue` C++11/14 中的行为

c++ - 将 VS 移植到 linux : no matching function for call to

c++ - 运算符重载 : Ostream/Istream

objective-c - 无法在动态链接库 libintl-8.dll 中找到过程入口点 __printf__

java - 如何在 IntelliJ 中运行新的基于 Maven 的 “quickstart” 应用程序?

java - J2ME - 在一个项目中支持不同平台

c++ - C 在运行时发出警告?

c++ - 如何在 Eclipse C++ 中使用 -std-c++11

c - 如何在cmd窗口中而不是在控制台npp中获取C程序的输出

c - vim如何实现跨目录的符号引用?