![](/img/trans.png)
[英]Compiler error in mingw-w64: 'undefined reference to `__getreent.'
[英]Undefined reference using Allegro 5 with mingw-w64
我正在尝试使用mingw-w64在Windows 10上编译Allegro 5程序。
我已经安装了mingw-w64。 g++ --version
输出是:
g++.exe (i686-posix-dwarf-rev2, Built by MinGW-W64 project) 7.1.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我从https://github.com/liballeg/allegro5/releases下载了Allegro 5的Windows二进制文件(文件: allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.0.zip
)并将文件解压缩到C:/allegro5
所以现在我有了C:/allegro5/bin
, C:/allegro5/include
, C:/allegro5/lib
。
一个小测试程序:
#include <stdio.h> #include <allegro5/allegro.h> int main(int argc, char **argv) { al_init(); return 0; }
最后运行我要编译的命令: g++ test.cpp -I"C:/allegro5/include" -L"C:/allegro5/lib" -lallegro
( C:/allegro5/lib
下有一个名为liballegro.dll.a
的lib文件C:/allegro5/lib
)
但是链接时存在一些问题:
C:\Users\xxxx\AppData\Local\Temp\ccg5z97Y.o:test.cpp:(.text+0x1e): undefined reference to `al_install_system'
collect2.exe: error: ld returned 1 exit status
A)这可能是什么原因?
B)我应该怎么做才能以静态方式进行编译? 将-lallegro
更改为-lallegro-static
足够?
这个:
g++.exe (i686-posix-dwarf-rev2, Built by MinGW-W64 project) 7.1.0
是MinGW-W64提供的32位GCC变体之一。 您试图将其生成的32位代码与以下位置提供的64位库链接:
allegro-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.0.zip
这将无法正常工作。 用适当的64位变体x86_64-posix-seh替换您的编译器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.