首页 > 解决方案 > 使用 cygwin 编译 C++/SDL2/OpenGL 项目

问题描述

我正在尝试在 Windows 上编译一个通常在 MacOSX 上运行的项目。我有一个 makefile,我也想在 Windows 上使用它。问题是我不明白这个错误:

/usr/lib/gcc/x86_64-pc-cygwin/7.3.0/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-2.11.2-1/winsup/cygwin/lib/libcmain.c:37: undefined reference to `WinMain'
/usr/src/debug/cygwin-2.11.2-1/winsup/cygwin/lib/libcmain.c:37:(.text.startup+0x7f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
make: *** [makefile:70: program] Error 1

编译命令是:

g++ -o program path/to/a/lot/of/obj/obj.o -lGLEW -lGLU -lGL -lSDL2main -lSDL2

Cygwin 中有一个类似的主题Undefined reference to WinMain但该解决方案对我没有帮助。我的 makefile 在 MacOSX 上运行良好。

标签: c++windowsopenglmakefilesdl-2

解决方案


推荐阅读