SFML community forums

Help => General => Topic started by: Zanaran on April 16, 2015, 03:55:16 am

Title: [SOLVED]Undefined reference to blahblahblah in CodeBlocks
Post by: Zanaran on April 16, 2015, 03:55:16 am
There are several people out there with the same problem as me, but the solutions they were given were either unclear or didn't help me.
I am using Windows 7 x86, Code Blocks Release 12.11 rev 8629, and SFML 2.2 GCC 4.8.1 TDM (SJLJ) - 32-bit. I have followed the instructions of the tutorial as best as I could but I still get this in the build log:

(click to show/hide)

I set the compiler and linker search directories to be global for both debug and release, and same for the dependencies that I used.
(http://puu.sh/hfv8r/cf63f3e328.png)
The settings for the debug and release are the same except for the -d suffix which is only for debug.
(http://puu.sh/hfvf5/ad0cb1db9c.png)
And I globally defined static under Compiler settings > #defines.
(http://puu.sh/hfvlb/5fc2827a37.png)
The code I wanted to compile is the same as the tutorial code.
(click to show/hide)

Did I do anything wrong here? Is there something I didn't mention also?

SOLVED: Solution is here for anyone who has the same problem:
These in your project-wide linker settings:
  • glew
  • freetype
  • jpeg
  • opengl32
  • gdi32
  • winmm
These in your debug build target settings:
  • sfml-graphics-s-d
  • sfml-window-s-d
  • sfml-system-s-d
These in your release build target settings:
  • sfml-graphics-s
  • sfml-window-s
  • sfml-system-s
Don't forget to change the linker policy of your targets to Prepend target options to project options, as I showed in the picture I posted.
Title: AW: Undefined reference to blahblahblah in CodeBlocks
Post by: eXpl0it3r on April 16, 2015, 09:25:50 am
The order is wrong. I've personally not found a way to tell where the global libs should be added. As such you'll have to add all the global libs to debug and release instead.
Title: Re: AW: Undefined reference to blahblahblah in CodeBlocks
Post by: binary1248 on April 16, 2015, 09:59:16 am
The order is wrong. I've personally not found a way to tell where the global libs should be added. As such you'll have to add all the global libs to debug and release instead.
(http://i.imgur.com/ZDAWEEf.png)
Title: Re: Undefined reference to blahblahblah in CodeBlocks
Post by: eXpl0it3r on April 16, 2015, 10:12:04 am
Oh. :)
Title: Re: AW: Undefined reference to blahblahblah in CodeBlocks
Post by: Zanaran on April 17, 2015, 01:18:45 am
The order is wrong. I've personally not found a way to tell where the global libs should be added. As such you'll have to add all the global libs to debug and release instead.
I followed your instructions and put the libraries back where they should be but now I get a DLL error because apparently I'm missing OpenGL32. What do I do now?
Title: Re: Undefined reference to blahblahblah in CodeBlocks
Post by: binary1248 on April 17, 2015, 02:20:27 am
Show the new build log.
Title: Re: Undefined reference to blahblahblah in CodeBlocks
Post by: Zanaran on April 17, 2015, 02:28:30 am
Shoot, was about to say.
(click to show/hide)
Title: Re: Undefined reference to blahblahblah in CodeBlocks
Post by: G. on April 17, 2015, 02:33:37 am
Your linking order is still wrong, and now you're linking SFML twice! Dependencies should come after libs that are dependent of them.
Title: Re: Undefined reference to blahblahblah in CodeBlocks
Post by: Zanaran on April 17, 2015, 02:37:08 am
This is the linking order that I have:
(http://puu.sh/hgzsk/9b9683ede4.png)
Did I mess something up or is there a better way to link like this?
Title: Re: Undefined reference to blahblahblah in CodeBlocks
Post by: binary1248 on April 17, 2015, 02:40:15 am
These in your project-wide linker settings:
These in your debug build target settings:
These in your release build target settings:
Don't forget to change the linker policy of your targets to Prepend target options to project options, as I showed in the picture I posted.
Title: Re: Undefined reference to blahblahblah in CodeBlocks
Post by: Zanaran on April 17, 2015, 02:50:18 am
These in your project-wide linker settings:
  • glew
  • freetype
  • jpeg
  • opengl32
  • gdi32
  • winmm
These in your debug build target settings:
  • sfml-graphics-s-d
  • sfml-window-s-d
  • sfml-system-s-d
These in your release build target settings:
  • sfml-graphics-s
  • sfml-window-s
  • sfml-system-s
Don't forget to change the linker policy of your targets to Prepend target options to project options, as I showed in the picture I posted.
Just did it, and finally, it worked!
(http://puu.sh/hgzXP/80c06ed1e6.png)
Thanks a ton, by the way. I spent about two days trying to figure this out and now I feel dumb.