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

Author Topic: Dynamic linking to SFML (github master branch) under Ubuntu 16.04 fails  (Read 7340 times)

0 Members and 1 Guest are viewing this topic.

amhndu

  • Newbie
  • *
  • Posts: 42
  • Err, err and err again, but less, less and less
    • View Profile
    • amhndu.github.io
    • Email
Compiling the library with SHARED=TRUE/FALSE works and the examples compile/run when built with SHARED=FALSE but when linked dynamically, the following error comes up:

Code: [Select]
/usr/bin/ld: opengl: hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a(cpuinfo.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
examples/opengl/CMakeFiles/opengl.dir/build.make:111: recipe for target 'examples/opengl/opengl' failed
make[2]: *** [examples/opengl/opengl] Error 1
CMakeFiles/Makefile2:494: recipe for target 'examples/opengl/CMakeFiles/opengl.dir/all' failed
make[1]: *** [examples/opengl/CMakeFiles/opengl.dir/all] Error 2

This is pretty much the same error that comes up when linking any other SFML project.

g++ version: 5.3.1 (5.3.1-14ubuntu2)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
It's unfortunately a bug in GCC 5.x. They say that it's fixed upstream and they'll most likely back-port it.
In the meantime there's this workaround provided by someone in the comments.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

amhndu

  • Newbie
  • *
  • Posts: 42
  • Err, err and err again, but less, less and less
    • View Profile
    • amhndu.github.io
    • Email
Thanks, that worked!

As a side question/request, could we have a wiki page or something which details these kind of workarounds and gotchas for compiling SFML ? IIRC, I had to manually edit some header file (I think something related to std image...) under Ubuntu 15.04 ...

Also, are you guys not involved in packaging SFML 2.3 in the SFML repos ? It also had this same problem with dynamic linking and also all the header files it installed were `.h` instead of `.hpp`, that would break every SFML project.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
The wiki is an open place, so anyone can start something like that. Thing is these kinds of bugs appear and disappear, thus having to maintain it can be a bit time consuming, plus in many cases it's rather hard to track down the actual issue or to differentiate between user error and actual bug. Also how far would one want to track third-party bugs? ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

amhndu

  • Newbie
  • *
  • Posts: 42
  • Err, err and err again, but less, less and less
    • View Profile
    • amhndu.github.io
    • Email
Quote
The wiki is an open place, so anyone can start something like that. Thing is these kinds of bugs appear and disappear, thus having to maintain it can be a bit time consuming, plus in many cases it's rather hard to track down the actual issue or to differentiate between user error and actual bug. Also how far would one want to track third-party bugs?

You are right, it could get tedious, but if there were already some base I will have no problem contributing, since I'm not sure how would I start such a page.

Also, my other question:
Quote
Also, are you guys not involved in packaging SFML 2.3 in the SFML repos ? It also had this same problem with dynamic linking and also all the header files it installed were `.h` instead of `.hpp`, that would break every SFML project.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Oh right, I forgot about the second question. No we're not involved in that. Do they really pack .h headers? That sounds quite odd.
What package did you actually use? libsfml-dev for example comes with hpp headers on newer Ubuntu distributions.
« Last Edit: June 03, 2016, 11:25:40 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/

amhndu

  • Newbie
  • *
  • Posts: 42
  • Err, err and err again, but less, less and less
    • View Profile
    • amhndu.github.io
    • Email
That's odd.. xenial also lists hpps.. I could've sworn I saw .hs when I installed it. Although, I had already installed sfml using make before that, I found both .hpps and .hs in the include directory and after I removed the package, only the .hs were gone...

You know what, never mind this..

And thanks again for your help and indulging me

user31182

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Dynamic linking to SFML (github master branch) under Ubuntu 16.04 fails
« Reply #7 on: August 02, 2016, 05:59:11 pm »
Is there any way to use this workaround with a command line build, eg

g++ main.o -lsfml-graphics -lsfml-window -lsfml-system -o a.out

Can I modify the above command to "make my sfml program link properly with g++5"?

user31182

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: Dynamic linking to SFML (github master branch) under Ubuntu 16.04 fails
« Reply #8 on: August 02, 2016, 06:39:02 pm »
This bug also shows up in g++-4.9 under ubuntu 16.04 by the way

coolp_jim

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Dynamic linking to SFML (github master branch) under Ubuntu 16.04 fails
« Reply #9 on: February 16, 2017, 10:34:36 pm »
This is still an issue with fresh Ubuntu 16.04.4, gcc 5.4.0, fresh clone of SFML. Error I get when running compiled example now is:

/usr/bin/ld: a.out: hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a(cpuinfo.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Is there any fix for this? The CMakeLists.txt file no longer has the lines the aforementioned patch affects.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Dynamic linking to SFML (github master branch) under Ubuntu 16.04 fails
« Reply #10 on: February 17, 2017, 11:33:30 am »
Have you tried adding -lgcc_s -lgcc to your linker command line?

coolp_jim

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Dynamic linking to SFML (github master branch) under Ubuntu 16.04 fails
« Reply #11 on: February 17, 2017, 02:03:11 pm »
I ended up grabbing g++-6 and using it to build SFML and my test project, that seems to work.

 

anything