【发布时间】:2021-05-31 13:02:22
【问题描述】:
使用 SFML 在 c++ 中制作了一个简单的基于 sprite 的 2d 游戏。它在 linux 上编译和运行都很好,但我希望能够在 windows 上编译它
我已经从https://www.sfml-dev.org/download/sfml/2.5.1/ 下载了(假定的)正确版本的 sfml for code::blocks this one 并相应地配置了 GNU GCC 编译器搜索路径:
运行代码后,我收到 152 个“未定义的对...的引用”错误
然后在将库添加到链接器设置之后
我遇到了这 12 个错误:
||=== 构建文件:“无项目”中的“无目标”(编译器:未知)===|
C:\sfmltest\main.o:main.cpp||未定义对_imp___ZN2sf5Music12openFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to _imp___ZN2sf5Music12openFromFileERKSs'的引用
C:\sfmltest\main.o:main.cpp||未定义对_imp___ZN2sf5Music12openFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to _imp___ZN2sf5Music12openFromFileERKSs'的引用
C:\sfmltest\main.o:main.cpp||未定义对_imp___ZN2sf4Font12loadFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to _imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'的引用
C:\sfmltest\main.o:main.cpp||未定义对_imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'| C:\sfmltest\main.o:main.cpp|| undefined reference to _imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'的引用
C:\sfmltest\main.o:main.cpp||未定义对_imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'| C:\sfmltest\main.o:main.cpp|| undefined reference to _imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'的引用
C:\sfmltest\main.o:main.cpp||更多未定义的对 `_imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE' 的引用如下|
||错误:ld 返回 1 个退出状态|
||=== 构建失败:12 个错误,0 个警告(0 分钟,2 秒)===|
我错过了什么?
【问题讨论】:
-
通常名称中带有 d 的库是 Debug 库,没有它的是 Release。与他们联系起来非常奇怪。尝试仅链接 d-libraries 或仅链接 no-d-libraries。您可以为 Debug && Release 定义不同的集合。我想知道它是否有帮助。
-
将
lsfml-systemlsfml-windowlsfml-graphics添加到构建选项下的链接库(对于代码::块 v20.03)应该就足够了,您可以尝试将这些添加到您的链接器设置中吗? (如果您使用的是网络和音频,只需通过替换后缀来添加它们)
标签: c++ gcc codeblocks sfml