我正在尝试使用mingw-w64在Windows 10上编译Allegro 5程序。
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.
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
(在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
?
这个:
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替换您的编译器