我一直在尝试让 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’
所以我认为这可能是由于没有使用 include,所以我将 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**
而且我不知道该怎么做才能解决它。
最佳答案
简答
添加 -arch i386
(在 mac 上)或 -m32
(在 linux 上)标志
长答案
您的 sfml-system
库是在 32 位中构建的,而您正试图在 64 位中编译您的程序。所以你的程序无法链接到库。
如果可能,在 64 位中重新编译 SFML,您应该能够在 64 位中编译您的程序。
关于c++ - 在 GCC 和 OS X 中使用 SFML 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10111680/