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

Author Topic: [SOLVED] Static linking - undefined references  (Read 2473 times)

0 Members and 1 Guest are viewing this topic.

Raincode

  • Full Member
  • ***
  • Posts: 118
    • View Profile
[SOLVED] Static linking - undefined references
« on: October 18, 2014, 11:26:48 pm »
Hi there,

I have been using SFML for a while now, always linking dynamically. But I want to be able to run my program without copying a bunch of dll's around, also I just wanted to try linking statically in generell.

I have failed at this before, so I decided  to build  sfml from the snapshot source right away.
Worked perfectly. I build Debug as well as Release static libs with Compiler A.

Then I added Compiler A to QtCreator, added a new Kit with Compiler A and made it default.

Then I added the SFML include path to my project.
Then I added the SFML lib path along with -lsfml-system-s-d -lsfml-window-s-d -lsfml-graphics-s-d to my project.
I set the build mode to Debug.
I add #define SFML_STATIC to my config file (though I heard this is standard anyway)
I click build and get a couple dozen of undefined references all looking kind of like this:
... to `_imp__ZN2sf<...>` whereas <...> are some sort of class or function names mixed with numbers

I really don't know why it isn't working. But please don't tell me to link "in the right order", because I have, I even tried it in reversed order -> no change
Also I am running debug libs in debug mode etc.

Compiler is version 4.8.1 from the MinGW package or whatever it is called. If I can give you any additional information which could help solve my problem, please, let me know.
« Last Edit: October 19, 2014, 10:45:58 am by Raincode »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10823
    • View Profile
    • development blog
    • Email
"haven't found solution in any threads" = I didn't read carefully enough to understand the solutions given in tons of other threads.

"_imp_" means the linker is looking for import symbols, which means it's looking for dynamically linked stuff, which in turn means it's looking for the SFML import libraries and not the static ones. This again means that SFML_STATIC hasn't been defined (at the right place).

SFML_STATIC - as described in the tutorials - needs to be added to the compiler settings and not at some random place in your source code.
« Last Edit: October 18, 2014, 11:42:02 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raincode

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Hi,

thank you very much for your reply.

I have tried a third method, which makes the _imp__ disappear, yet greets me with 391 new errors, also undefined references, with many glew, gl and sf "components".

changed order of libs, now all sf undefined references disappeared. 231 gl, wgl, jpeg,  glew etc remain :/ They also contain @4's or @8's etc. at the end, if that helps at all.

I will have to get back to this tomorrow. Have been trying to get this running for hours... so exhausting, lol

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10823
    • View Profile
    • development blog
    • Email
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Raincode

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Wow, thanks so much, this resolved my problems. I was suspecting something being wrong with external dependencies, and I even tried including the extlib headers, but then failed to link the libs.

But that link explains everything and which libs to link, it was very simple thank you.

I really have to improve my researching skills I feel... hah

Anyway, again thank you for helping out eXpl0it3r