【发布时间】:2019-07-29 06:13:06
【问题描述】:
我正在尝试使用 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-x86_64-w64-mingw32-gcc-8.2.1-posix-seh-static-5.2.5.0.zip)下载了 Allegro 5 的 Windows 二进制文件,并将文件解压缩到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:\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 是否足够?
【问题讨论】:
标签: c++ linker linker-errors allegro5