简体   繁体   English

带有mingw32的SFML2静态链接错误:未定义的引用

[英]SFML2 static linking error with mingw32: undefined references

I am using Code::Blocks on 64bit Windows 7, MinGW 4.7.1. 我在64位Windows 7,MinGW 4.7.1上使用Code :: Blocks。

I'm trying to get SFML 2.1 to work with MingW in codeblocks, but it's causing problems. 我正在尝试使SFML 2.1在代码块中与MingW一起使用,但这会引起问题。

when i try to compile i get these errors: 当我尝试编译时,出现以下错误:

undefined reference to _imp___ZN2sf6StringC1EPKcRKSt6locale _imp___ZN2sf6StringC1EPKcRKSt6locale未定义引用

undefined reference to _imp___ZN2sf9VideoModeC1Ejjj _imp___ZN2sf9VideoModeC1Ejjj未定义引用

... ...

I'm linking the following libraries: 我正在链接以下库:

  • sfml-graphics SFML显卡
  • sfml-window SFML窗口
  • sfml-system SFML系统

What am I doing wrong? 我究竟做错了什么? The errors say undefined reference, but I have already follow these instructions step by step. 错误提示未定义参考,但是我已经逐步遵循了这些说明

When trying to link the static version of the library, you'll essentially have to use the static version of the headers as well (otherwise you're essentially looking for the references at the wrong place (more specifically: with the wrong format/decoration)). 尝试链接库的静态版本时,您实际上也必须使用标头的静态版本(否则,您实际上是在错误的位置查找引用(更具体地说:格式/修饰错误) ))。

As such, when linking the static version, always make sure that SFML_STATIC is defined before you include any SFML header. 这样,在链接静态版本时,请始终确保在包含任何SFML标头之前已定义SFML_STATIC

Also, make sure to link the static version of the libraries (with a -s suffixed). 另外,请确保链接库的静态版本(后缀-s )。


Static SFML 静态SFML

  • Define SFML_STATIC . 定义SFML_STATIC
  • Link to sfml-system-s , sfml-window-s , sfml-graphics-s , etc. (or their debug versions). 链接到sfml-system-ssfml-window-ssfml-graphics-s等(或它们的调试版本)。

Dynamic SFML 动态SFML

  • Do not define SFML_STATIC . 不要定义SFML_STATIC
  • Link to * sfml-system*, sfml-window , sfml-graphics , etc. (or their debug versions). 链接到sfml-system, sfml-windowsfml-graphics等(或其调试版本)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM