Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Answered] Building "undefined references": SFML 2.2 32 bit MinGW gcc 4.7.1  (Read 2696 times)

0 Members and 1 Guest are viewing this topic.

thecheeselover

  • Newbie
  • *
  • Posts: 24
    • View Profile
    I have followed the newest SFML 2.2 tutorial to build/compile SFML and link it to my project(s). So I built SFML 2.2 in debug and release mode for MinGW 32 bit (gcc 4.7.1) and it worked just fine as my 64 bit release builds (MinGW 64 gcc 4.9.0, TDM 64 gcc 4.8.1 and TDM 64 gcc 4.9.2). The .a files seemed to work just fine until I tried the simple example for drawing a green circle. I have no bugs in 64 bit with either of my compilers but when I'm in 32 bit with MinGW gcc 4.7.1, I get "undefined references at every line".

    Here's my build log:
(click to show/hide)

How my linking process work is that I link every optional libraries at the end of each build target, except for glew  because in 64 bit its name is glew32 (wtf Microsoft...). Then, in each build target, I add the respective link to each sfml libraries. For example, if it's a debug target, then I add -d but they all have -s. Also, depending on the architecture, I give the search directories for the linker:

    32 bit
    • extlibs\bin\x86
    • cmake build\Debug\lib\MinGW 32 (SFML 2.2 source I built myself)
    • extlibs\libs-mingw\x86
    64 bit
    • extlibs\bin\x64
    • cmake build\Release\lib\MinGW 64 (SFML 2.2 source I built myself, MinGW 64 is an example)
    • extlibs\libs-mingw\x64

    TL;DR
    64 bit works fine, 32 bit doesn't work. The only differences are glew and searching directories. Everything except the external libraries is compiled by myself.
[/list]
« Last Edit: January 05, 2015, 10:10:41 pm by thecheeselover »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Building "undefined references": SFML 2.2 32 bit MinGW gcc 4.7.1
« Reply #1 on: January 05, 2015, 01:28:33 am »
It seems to work fine on my end.

Are you absolutely certain that you're using the right libraries and Code::Blocks doesn't suddenly find other SFML libraries?
If you build SFML with SFML_USE_STATIC_STD_LIBS and a TDM compiler, you don't have to add -static-libgcc to the compiler flags. If you haven't checked that CMake option, you have to provide -shared-ligcc and -shared-libstdc++.
You can also remove your -DDGLEW_STATIC flag.
If you check SFML_BUILD_EXAMPLES when building SFML, do you get errors? If not, then it has to be an issue in your settings.
And last but not least, if you build the install target for static SFML, SFML's dependencies will get automatically copied to the lib and include directories, so you don't have to add the paths to the extlibs dir.
« Last Edit: January 05, 2015, 01:32:15 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

thecheeselover

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Building "undefined references": SFML 2.2 32 bit MinGW gcc 4.7.1
« Reply #2 on: January 05, 2015, 02:00:53 am »
Quote
If you check SFML_BUILD_EXAMPLES when building SFML, do you get errors?

Nope, because I checked SFML_BUILD_DOC, SFML_BUILD_EXAMPLES and SFML_USE_STATIC_STD_LIBS. I remember that checking BUILD_SHARED_LIBS and SFML_USE_STATIC_STD_LIBS at the same times provoked errors, so I uncheked BUILD_SHARED_LIBS. Anyway, I don't want any dll; I just want static librairies.

Quote
Are you absolutely certain that you're using the right libraries and Code::Blocks doesn't suddenly find other SFML libraries?
Actually, I'm unsure. All the paths I use point to the new SFML 2.2, but is there a way they could point to an old SFML? :O For example, if SFML is in the PATH?

EDIT: I tried sfml-graphics-s-d and everything with absolute paths but nothing changes.

Quote
And last but not least, if you build the install target for static SFML, SFML's dependencies will get automatically copied to the lib and include directories, so you don't have to add the paths to the extlibs dir.

Hmmm it doesn't do that for me...
« Last Edit: January 05, 2015, 02:04:40 am by thecheeselover »

thecheeselover

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Building "undefined references": SFML 2.2 32 bit MinGW gcc 4.7.1
« Reply #3 on: January 05, 2015, 10:10:27 pm »
Ok that's was really hard to find but, I guess that after installing multiple compilers, my PATH variable got mixed up. What happened is that CB's MinGW default compiler has been replaced by a TDM compiler. When I was using CMake, I was checking "Use default native compilers" when I should have given the old MinGW's g++ and gcc path. Now it works! :)

 

anything