gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 07:23:16 28 4
gpt4 key购买 nike

我正在尝试使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com