我试图在mac os x上使用SFML编译最小项目。我使用以下命令:
g++ -o rj -framework SFML -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system main.cpp
使用以下代码:
# include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "test");
return 0;
}
并收到错误:
Undefined symbols for architecture x86_64:
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in main-15430b.o
ld: symbol(s) not found for architecture x86_64
我做错了什么?
答案 0 :(得分:1)
我有同样的问题。我像在 tutorial中那样安装SFML,然后放入框架并确定了dylib。但是,当我想编译hello world程序时,我会遇到如下问题:
undefined symbols for architecture x86_64:
"sf::CircleShape::CircleShape(float, unsigned long)", referenced from:
_main in main-1b3038.o
"sf::RenderStates::Default", referenced from:
_main in main-1b3038.o
"sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)", referenced from:
_main in main-1b3038.o
"sf::RenderTarget::clear(sf::Color const&)", referenced from:
_main in main-1b3038.o
"sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
_main in main-1b3038.o
...
当我这样做时:
clang++ main.cpp -I /usr/local/include
我的SFML库路径为:/usr/local/include/SFML
答案 1 :(得分:0)
通过安装clang版本的库来解决问题。