在MinGW上使用SFML

时间:2019-01-20 03:04:05

标签: c++ windows 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

谢谢。

1 个答案:

答案 0 :(得分:0)

如果源代码位于文件夹中,则可能需要将其移至g ++,c ++或正在使用的任何编译器所在的文件夹中。或者只是制作各种复制移动脚本。