SFML 2.5.1 和 CodeBlocks with GCC 5.1.0 - 项目编译错误
SFML 2.5.1 and CodeBlocks with GCC 5.1.0 - project compiling errors
我已经下载了 CodeBlocks (GCC 5.1.0 TDM (SJLJ)) 的 SFML 2.5.1 包,即使遵循了 SFML 指南,我仍然无法在此 IDE 中启动我的应用程序。我尝试了多种方法,但都失败了。有人可以通过从错误日志中得出结论来给我一些关于这个问题的提示吗?谢谢。我的编译器是 GCC 5.1.0,我的代码是来自 the SFML site 的示例。
建造者:
1 个来自 SFML 包的动态库。项目构建没有错误,但是当我用午餐程序时,我收到此消息:
Cannot find the entry point of procedure
_ZNKSt7_cxx1112basic_stringlcSt11char_traitslcESalcEE12find_last_ofEPKcj
in DLL-file [project path] sfml-system-d-2.dll
(所有库都会出现此错误 - 系统、图形和 window)。
2 个来自 SFML 包的静态库:
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
C:\Users\user\Desktop\SFML-2.5.1\lib\libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp|| undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'|
C:\Users\user\Desktop\SFML-2.5.1\lib\libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp|| undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'|
C:\Users\user\Desktop\SFML-2.5.1\lib\libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp|| undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'|
||error: ld returned 1 exit status|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
在此之后,我决定使用 CMake 和 CodeBlock makefile 构建 SFML。
3 个内置静态库("include" 来自 SFML 包,以及 openal32 和 freetype dll):
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp:(.text.startup+0xc4)||undefined reference to `sf::String::String(char const*, std::locale const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0xf3)||undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0xea)||undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x12a)||undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0x13a)||undefined reference to `sf::Color::Green'|
obj\Release\main.o:main.cpp:(.text.startup+0x149)||undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x161)||undefined reference to `sf::Window::isOpen() const'|
obj\Release\main.o:main.cpp:(.text.startup+0x198)||undefined reference to `sf::Window::pollEvent(sf::Event&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1c9)||undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1e0)||undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f7)||undefined reference to `sf::RenderStates::Default'|
obj\Release\main.o:main.cpp:(.text.startup+0x1ff)||undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x20d)||undefined reference to `sf::Window::display()'|
obj\Release\main.o:main.cpp:(.text.startup+0x231)||undefined reference to `sf::Window::close()'|
obj\Release\main.o:main.cpp:(.text.startup+0x246)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x250)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x255)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x260)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2e3)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2ed)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2f2)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2fd)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
||error: ld returned 1 exit status|
||=== Build failed: 23 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
4 个内置动态库("include" 来自一个包):
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp:(.text.startup+0xc5)||undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
obj\Release\main.o:main.cpp:(.text.startup+0xf5)||undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
obj\Release\main.o:main.cpp:(.text.startup+0xed)||undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'|
obj\Release\main.o:main.cpp:(.text.startup+0x12e)||undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'|
obj\Release\main.o:main.cpp:(.text.startup+0x133)||undefined reference to `_imp___ZN2sf5Color5GreenE'|
obj\Release\main.o:main.cpp:(.text.startup+0x14f)||undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'|
obj\Release\main.o:main.cpp:(.text.startup+0x172)||undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
obj\Release\main.o:main.cpp:(.text.startup+0x1a9)||undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
obj\Release\main.o:main.cpp:(.text.startup+0x1db)||undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f3)||undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f8)||undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'|
obj\Release\main.o:main.cpp:(.text.startup+0x214)||undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'|
obj\Release\main.o:main.cpp:(.text.startup+0x223)||undefined reference to `_imp___ZN2sf6Window7displayEv'|
obj\Release\main.o:main.cpp:(.text.startup+0x242)||undefined reference to `_imp___ZN2sf6Window5closeEv'|
obj\Release\main.o:main.cpp:(.text.startup+0x24c)||undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
obj\Release\main.o:main.cpp:(.text.startup+0x26a)||undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
obj\Release\main.o:main.cpp:(.text.startup+0x276)||undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
obj\Release\main.o:main.cpp:(.text.startup+0x2ee)||undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
obj\Release\main.o:main.cpp:(.text.startup+0x30c)||undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
obj\Release\main.o:main.cpp:(.text.startup+0x318)||undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
||error: ld returned 1 exit status|
||=== Build failed: 21 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
5 我唯一一次成功启动 sfml 代码(但在代码块之外)是在我按照说明进行操作时 of this video。所以我尝试以这种方式构建 SFML 库:BUILD_SHARED_LIBS = false 和 SMFL_USE_STATIC_STD_LIBS = true.
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp:(.text.startup+0xc4)||undefined reference to `sf::String::String(char const*, std::locale const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0xf3)||undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0xea)||undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x12a)||undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0x13a)||undefined reference to `sf::Color::Green'|
obj\Release\main.o:main.cpp:(.text.startup+0x149)||undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x161)||undefined reference to `sf::Window::isOpen() const'|
obj\Release\main.o:main.cpp:(.text.startup+0x198)||undefined reference to `sf::Window::pollEvent(sf::Event&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1c9)||undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1e0)||undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f7)||undefined reference to `sf::RenderStates::Default'|
obj\Release\main.o:main.cpp:(.text.startup+0x1ff)||undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x20d)||undefined reference to `sf::Window::display()'|
obj\Release\main.o:main.cpp:(.text.startup+0x231)||undefined reference to `sf::Window::close()'|
obj\Release\main.o:main.cpp:(.text.startup+0x246)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x250)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x255)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x260)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2e3)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2ed)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2f2)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2fd)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
||error: ld returned 1 exit status|
||=== Build failed: 23 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
最初的错误很可能源自预编译二进制文件的 C++ 标准标志(可能没有 -std=c++11
)和您的项目设置。
为了成功 link对抗 SFML,我建议:
- 一定要按照官方教程一步一步来,不要跳过任何东西。
- 如果您 link 静态:
- 不要忘记在项目设置中定义SFML_STATIC
- 不要忘记link所有依赖项
- 链接顺序很重要,使用 rule of thumb "X depends on Y, so X comes before Y"
- 并始终确保使用相同的编译器版本来编译 SFML 和构建您的应用程序
我已经下载了 CodeBlocks (GCC 5.1.0 TDM (SJLJ)) 的 SFML 2.5.1 包,即使遵循了 SFML 指南,我仍然无法在此 IDE 中启动我的应用程序。我尝试了多种方法,但都失败了。有人可以通过从错误日志中得出结论来给我一些关于这个问题的提示吗?谢谢。我的编译器是 GCC 5.1.0,我的代码是来自 the SFML site 的示例。 建造者:
1 个来自 SFML 包的动态库。项目构建没有错误,但是当我用午餐程序时,我收到此消息:
Cannot find the entry point of procedure _ZNKSt7_cxx1112basic_stringlcSt11char_traitslcESalcEE12find_last_ofEPKcj in DLL-file [project path] sfml-system-d-2.dll
(所有库都会出现此错误 - 系统、图形和 window)。
2 个来自 SFML 包的静态库:
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
C:\Users\user\Desktop\SFML-2.5.1\lib\libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp|| undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'|
C:\Users\user\Desktop\SFML-2.5.1\lib\libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp|| undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'|
C:\Users\user\Desktop\SFML-2.5.1\lib\libsfml-graphics-s.a(Shader.cpp.obj):Shader.cpp|| undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int)'|
||error: ld returned 1 exit status|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
在此之后,我决定使用 CMake 和 CodeBlock makefile 构建 SFML。
3 个内置静态库("include" 来自 SFML 包,以及 openal32 和 freetype dll):
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp:(.text.startup+0xc4)||undefined reference to `sf::String::String(char const*, std::locale const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0xf3)||undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0xea)||undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x12a)||undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0x13a)||undefined reference to `sf::Color::Green'|
obj\Release\main.o:main.cpp:(.text.startup+0x149)||undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x161)||undefined reference to `sf::Window::isOpen() const'|
obj\Release\main.o:main.cpp:(.text.startup+0x198)||undefined reference to `sf::Window::pollEvent(sf::Event&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1c9)||undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1e0)||undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f7)||undefined reference to `sf::RenderStates::Default'|
obj\Release\main.o:main.cpp:(.text.startup+0x1ff)||undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x20d)||undefined reference to `sf::Window::display()'|
obj\Release\main.o:main.cpp:(.text.startup+0x231)||undefined reference to `sf::Window::close()'|
obj\Release\main.o:main.cpp:(.text.startup+0x246)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x250)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x255)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x260)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2e3)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2ed)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2f2)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2fd)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
||error: ld returned 1 exit status|
||=== Build failed: 23 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
4 个内置动态库("include" 来自一个包):
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp:(.text.startup+0xc5)||undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'|
obj\Release\main.o:main.cpp:(.text.startup+0xf5)||undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'|
obj\Release\main.o:main.cpp:(.text.startup+0xed)||undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'|
obj\Release\main.o:main.cpp:(.text.startup+0x12e)||undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'|
obj\Release\main.o:main.cpp:(.text.startup+0x133)||undefined reference to `_imp___ZN2sf5Color5GreenE'|
obj\Release\main.o:main.cpp:(.text.startup+0x14f)||undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'|
obj\Release\main.o:main.cpp:(.text.startup+0x172)||undefined reference to `_imp___ZNK2sf6Window6isOpenEv'|
obj\Release\main.o:main.cpp:(.text.startup+0x1a9)||undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'|
obj\Release\main.o:main.cpp:(.text.startup+0x1db)||undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f3)||undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f8)||undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'|
obj\Release\main.o:main.cpp:(.text.startup+0x214)||undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'|
obj\Release\main.o:main.cpp:(.text.startup+0x223)||undefined reference to `_imp___ZN2sf6Window7displayEv'|
obj\Release\main.o:main.cpp:(.text.startup+0x242)||undefined reference to `_imp___ZN2sf6Window5closeEv'|
obj\Release\main.o:main.cpp:(.text.startup+0x24c)||undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
obj\Release\main.o:main.cpp:(.text.startup+0x26a)||undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
obj\Release\main.o:main.cpp:(.text.startup+0x276)||undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
obj\Release\main.o:main.cpp:(.text.startup+0x2ee)||undefined reference to `_imp___ZTVN2sf11CircleShapeE'|
obj\Release\main.o:main.cpp:(.text.startup+0x30c)||undefined reference to `_imp___ZN2sf5ShapeD2Ev'|
obj\Release\main.o:main.cpp:(.text.startup+0x318)||undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'|
||error: ld returned 1 exit status|
||=== Build failed: 21 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
5 我唯一一次成功启动 sfml 代码(但在代码块之外)是在我按照说明进行操作时 of this video。所以我尝试以这种方式构建 SFML 库:BUILD_SHARED_LIBS = false 和 SMFL_USE_STATIC_STD_LIBS = true.
||=== Build: Release in SFML example (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp:(.text.startup+0xc4)||undefined reference to `sf::String::String(char const*, std::locale const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0xf3)||undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0xea)||undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x12a)||undefined reference to `sf::CircleShape::CircleShape(float, unsigned int)'|
obj\Release\main.o:main.cpp:(.text.startup+0x13a)||undefined reference to `sf::Color::Green'|
obj\Release\main.o:main.cpp:(.text.startup+0x149)||undefined reference to `sf::Shape::setFillColor(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x161)||undefined reference to `sf::Window::isOpen() const'|
obj\Release\main.o:main.cpp:(.text.startup+0x198)||undefined reference to `sf::Window::pollEvent(sf::Event&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1c9)||undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1e0)||undefined reference to `sf::RenderTarget::clear(sf::Color const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x1f7)||undefined reference to `sf::RenderStates::Default'|
obj\Release\main.o:main.cpp:(.text.startup+0x1ff)||undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'|
obj\Release\main.o:main.cpp:(.text.startup+0x20d)||undefined reference to `sf::Window::display()'|
obj\Release\main.o:main.cpp:(.text.startup+0x231)||undefined reference to `sf::Window::close()'|
obj\Release\main.o:main.cpp:(.text.startup+0x246)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x250)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x255)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x260)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2e3)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2ed)||undefined reference to `vtable for sf::CircleShape'|
obj\Release\main.o:main.cpp:(.text.startup+0x2f2)||undefined reference to `sf::Shape::~Shape()'|
obj\Release\main.o:main.cpp:(.text.startup+0x2fd)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
||error: ld returned 1 exit status|
||=== Build failed: 23 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
最初的错误很可能源自预编译二进制文件的 C++ 标准标志(可能没有 -std=c++11
)和您的项目设置。
为了成功 link对抗 SFML,我建议:
- 一定要按照官方教程一步一步来,不要跳过任何东西。
- 如果您 link 静态:
- 不要忘记在项目设置中定义SFML_STATIC
- 不要忘记link所有依赖项
- 链接顺序很重要,使用 rule of thumb "X depends on Y, so X comes before Y"
- 并始终确保使用相同的编译器版本来编译 SFML 和构建您的应用程序