使用带有mingw-w64的Allegro 5的未定义参考

问题描述 投票:0回答:1

我正在尝试使用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/binC:/allegro5/includeC:/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(在liballegro.dll.a下有一个名为C:/allegro5/lib的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
1个回答
2
投票

这个:

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替换您的编译器

© www.soinside.com 2019 - 2024. All rights reserved.