我尝试将 SFML 与代码块链接起来,但运行教程中的代码时出现一些错误。这是我在看到教程中的代码不起作用后尝试编写的代码:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
int main()
{
sf::Window w(sf::VideoMode(800,600),"da");
return 0;
}
This是我遵循的教程。
在我编译上面的代码后,它给了我 4 个错误:
||=== Build: Release in SFML1 (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp:(.text.startup+0x97)||undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
obj\Release\main.o:main.cpp:(.text.startup+0xc4)||undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
obj\Release\main.o:main.cpp:(.text.startup+0xaa)||undefined reference to `_imp___ZN2sf6WindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'|
obj\Release\main.o:main.cpp:(.text.startup+0xd3)||undefined reference to `_imp___ZN2sf6WindowD1Ev'|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
最佳答案
您犯了一个错误,或者没有严格按照教程进行操作。这可能会发生。每个人都会犯错误。重新开始并严格按照该教程进行操作。我们不可能知道您犯了哪个错误,因为要做到这一点,我们还需要逐步完成本教程并检查是否正确执行了所有步骤。
请注意,最新版本是 2.3,因此您应该遵循 2.3 tutorial .
关于c++ - SFML undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37366384/