我已经尝试让SFML工作了一段时间了,我也一直在尝试使用GCC来让它工作。顺便说一下,我用的是OS X。我遵循了标准的Linux指令,并使用Linux 64位下载,但是当涉及到编译时...
g++ -o testing main.cpp -lsfml-system
这种情况会发生:
main.cpp: In function ‘int main()’:
main.cpp:7: error: ‘class sf::Clock’ has no member named ‘GetElapsedTime’
main.cpp:9: error: ‘class sf::Clock’ has no member named ‘GetElapsedTime’
main.cpp:10: error: ‘Sleep’ is not a member of ‘sf’
所以我认为这可能是因为没有使用includes,所以我将我的gcc编译命令更改为:
g++ -o testing main.cpp -I ~/SFML-1.6/include/ -lsfml-system
现在我得到了这个错误:
ld: warning: ignoring file /usr/local/lib/libsfml-system.so, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"sf::Clock::Clock()", referenced from:
_main in ccZEiB7b.o
"sf::Clock::GetElapsedTime() const", referenced from:
_main in ccZEiB7b.o
"sf::Sleep(float)", referenced from:
_main in ccZEiB7b.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status**
我不知道该怎么解决它。
发布于 2012-04-11 18:25:51
简短的回答
添加-arch i386
(在mac上)或-m32
(在linux上)标志
长长的答案
你的sfml-system
库是用32位构建的,而你正试图用64位编译你的程序。因此,您的程序无法链接到该库。
如果可能的话,重新编译64位的SFML,你应该能够用64位编译你的程序。
发布于 2012-04-11 23:25:41
打开SFML文件夹,将lib64下的所有文件夹复制到/Library/Frameworks (即,将SFML.framework、sfml-system.framework等复制到/Library/ frameworks )。
一旦安装了框架,就可以通过将-framework命令传递给g++来使用它们,如下所示:
g++ -o testing main.cpp -framework SFML -framework sfml-system
https://stackoverflow.com/questions/10111680
复制相似问题