Question

I am using Code::Blocks on 64bit Windows 7, MinGW 4.7.1.

I'm trying to get SFML 2.1 to work with MingW in codeblocks, but it's causing problems.

when i try to compile i get these errors:

undefined reference to _imp___ZN2sf6StringC1EPKcRKSt6locale

undefined reference to _imp___ZN2sf9VideoModeC1Ejjj

...

I'm linking the following libraries:

  • sfml-graphics
  • sfml-window
  • sfml-system

What am I doing wrong? The errors say undefined reference, but I have already follow these instructions step by step.

Was it helpful?

Solution

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.

Also, make sure to link the static version of the libraries (with a -s suffixed).


Static SFML

  • Define SFML_STATIC.
  • Link to sfml-system-s, sfml-window-s, sfml-graphics-s, etc. (or their debug versions).

Dynamic SFML

  • Do not define SFML_STATIC.
  • Link to * sfml-system*, sfml-window, sfml-graphics, etc. (or their debug versions).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top