无法与 mingw 交叉编译 opengl 程序

Can't cross compile opengl program with mingw

本文关键字:opengl 程序 交叉编译 mingw      更新时间:2023-10-16

我想从 debian 编译适用于 Windows 的程序

> '/opt/mingw32/bin/i686-w64-mingw32-g++' '/home/redrockfish/Projects/OpenGl0/main.cpp' -o arcanoid.exe -static-libstdc++ -static-libgcc -lglu32 -lopengl32 -lglut32
/tmp/ccrvQIKM.o:main.cpp:(.text+0x1c): undefined reference to `_imp____glutInitWithExit@12'
/tmp/ccrvQIKM.o:main.cpp:(.text+0x3e): undefined reference to `_imp____glutCreateWindowWithExit@8'
/tmp/ccrvQIKM.o:main.cpp:(.text+0x60): undefined reference to `_imp____glutCreateMenuWithExit@8'
/opt/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.9.0/../../../../i686-w64-mingw32/bin/ld: /tmp/ccrvQIKM.o: bad reloc address 0x0 in section `.ctors'
collect2: error: ld returned 1 exit status

如果我删除-lglut32则未确定的引用数量会增加。 标题,如果Freeglut.h,取自官方网站。 用glut替换glut32,添加-lGLU没有帮助。 与 -lGL

cannot find -lGL
collect2: error: ld returned 1 exit status

__glutCreateWindowWithExit这样的函数不是官方 GLUT API 的一部分。实际上,该函数是由freeglut(甚至不是其外部API的一部分(进行的扩展,因此您不能链接一些随机的GLUT DLL,而是链接freeglut(可用于Windows(。