簡體   English   中英

在 CodeBlocks 中編譯 SFML 項目的問題

[英]Issue with compiling SFML project in CodeBlocks

使用 SFML 在 c++ 中制作了一個簡單的基於精靈的 2d 游戲。 它在 linux 上編譯和運行得很好,但我希望能夠在 windows 上編譯它

我已經從https://www.sfml-dev.org/download/sfml/2.5.1/下載了(假定的)正確版本的 sfml for code::blocks這個版本,並相應地配置了 GNU GCC 編譯器搜索路徑:

編譯器搜索路徑

linker 搜索路徑

c++11 標准啟用

運行代碼后,我得到 152“未定義的引用...”錯誤

然后將庫添加到 linker 設置后

linker 設置

我留下了這 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|| undefined reference to 對_imp___ZN2sf5Music12openFromFileERKSs'的_imp___ZN2sf5Music12openFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to | 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|| undefined reference to 對_imp___ZN2sf5Music12openFromFileERKSs'的_imp___ZN2sf5Music12openFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to | C:\sfmltest\main.o:main.cpp|| _imp___ZN2sf4Font12loadFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to _imp___ZN2sf4Font12loadFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to _imp___ZN2sf4Font12loadFromFileERKSs'| C:\sfmltest\main.o:main.cpp|| undefined reference to 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|| undefined reference to _imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'| C:\sfmltest\main.o:main.cpp|| undefined reference to 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|| undefined reference to _imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE'| C:\sfmltest\main.o:main.cpp|| undefined reference to C:\sfmltest\main.o:main.cpp|| 更多未定義的對 `_imp___ZN2sf7Texture12loadFromFileERKSsRKNS_4RectIiEE' 的引用如下| ||錯誤:ld 返回 1 個退出狀態| ||=== 構建失敗:12 個錯誤,0 個警告(0 分鍾,2 秒)===|

我錯過了什么?

您沒有定義SFML_STATIC這就是 linker 正在尋找_imp___ (即導入)符號的原因。

您列出的庫也是錯誤的。 您應該只列出一組庫。
例如 Static 和 Debug = sfml-*-sd
或 Static 和 Release = sfml-*-s

而當你靜態鏈接時,你還需要鏈接 SFML 的依賴項。

如果您按照有關如何使用 Code::Blocks 逐步設置 SFML 的官方教程進行操作,並且不只是查看圖像,那么事情應該可以正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM