在 MinGW 上使用 SFML
Using SFML on MinGW
我一直在研究 Gameboy 模拟器,一切看起来都很棒,我已经实现了核心、标志更新、周期精确中断等。我认为是时候看看一些东西了。
我为图形选择了SFML,到目前为止我已经能够编译示例程序了。但是,当我尝试编译我的模拟器时,实际的 C++ 标准库似乎没有链接,因为日志报告了来自 STD 方法的未定义引用,例如:
agb\main.o:main.cc:(.text+0x91): undefined reference to `__ZSt4cout'
agb\main.o:main.cc:(.text+0x120): undefined reference to `__ZNSt8ios_base4InitD1Ev'
agb\main.o:main.cc:(.text+0x141): undefined reference to `__ZNSt8ios_base4InitC1Ev'
而且,这个特别有趣:
C:/Users/Astherix/Desktop/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
有人知道为什么会这样吗?
我用的是自定义BAT编译,这是源码:
@echo off
set name=%1
echo Started building project '%name%' through gcc.
echo Creating object file '%name%.o'...
g++ -c %name%.cc -IC:\Users\Astherix\Desktop\mingw64\sfml\include
echo Compiling executable '%name%.exe'...
g++ %name%.o -o %name%.exe -LC:\Users\Astherix\Desktop\mingw64\sfml\lib -lsfml-graphics -lsfml-window -lsfml-system
提前致谢。
如果源代码在一个文件夹中,您可能希望将它移动到同一文件夹中的 g++、c++ 或您正在使用的任何编译器所在的文件夹。或者只是制作一个复制移动脚本。
我一直在研究 Gameboy 模拟器,一切看起来都很棒,我已经实现了核心、标志更新、周期精确中断等。我认为是时候看看一些东西了。
我为图形选择了SFML,到目前为止我已经能够编译示例程序了。但是,当我尝试编译我的模拟器时,实际的 C++ 标准库似乎没有链接,因为日志报告了来自 STD 方法的未定义引用,例如:
agb\main.o:main.cc:(.text+0x91): undefined reference to `__ZSt4cout'
agb\main.o:main.cc:(.text+0x120): undefined reference to `__ZNSt8ios_base4InitD1Ev'
agb\main.o:main.cc:(.text+0x141): undefined reference to `__ZNSt8ios_base4InitC1Ev'
而且,这个特别有趣:
C:/Users/Astherix/Desktop/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
有人知道为什么会这样吗?
我用的是自定义BAT编译,这是源码:
@echo off
set name=%1
echo Started building project '%name%' through gcc.
echo Creating object file '%name%.o'...
g++ -c %name%.cc -IC:\Users\Astherix\Desktop\mingw64\sfml\include
echo Compiling executable '%name%.exe'...
g++ %name%.o -o %name%.exe -LC:\Users\Astherix\Desktop\mingw64\sfml\lib -lsfml-graphics -lsfml-window -lsfml-system
提前致谢。
如果源代码在一个文件夹中,您可能希望将它移动到同一文件夹中的 g++、c++ 或您正在使用的任何编译器所在的文件夹。或者只是制作一个复制移动脚本。