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

Author Topic: How to fix the CPU hidden symbol linker error?  (Read 7860 times)

0 Members and 1 Guest are viewing this topic.

user31182

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
How to fix the CPU hidden symbol linker error?
« on: August 03, 2016, 09:16:12 pm »
I understand there is a well known about error which occurs on ubuntu 16.04 systems when attempting to compile and link a C++ program with the SFML libraries. The linker error is:

hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a(cpuinfo.o) is referenced by DSO

There is supposed to be a fix, see here: http://web.archive.org/web/20160509014317/https://gitlab.peach-bun.com/pinion/SFML/commit/3383b4a472f0bd16a8161fb8760cd3e6333f1782.patch

However I do not understand what I'm supposed to do using this information.

Currently I compile using the following command:

g++ --std=c++11 -Wall main.cpp -lsfml-graphics -lsfml-window -lsfml-system -o a.out

What should I do to fix this linker error?

PS: Sorry to start a new thread on this - I did bump an older thread but the fix there had something to do with cmake, and I'm not using a cmake system here.

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: How to fix the CPU hidden symbol linker error?
« Reply #1 on: August 04, 2016, 05:48:19 pm »
The link provides a git patch. Clone the SFML repository using git, download the patch and apply it (the patch modifies the cmake file). Then build the SFML source from the patched repository and install it as usual. Linking against this version of SFML should fix the error.

user31182

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: How to fix the CPU hidden symbol linker error?
« Reply #2 on: August 04, 2016, 10:02:55 pm »
So this patch must be applied to the build of the SFML libraries rather than the build of my own program which *uses* SFML?

I which case, how to I clone and apply the patch?

user31182

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: How to fix the CPU hidden symbol linker error?
« Reply #3 on: August 04, 2016, 10:50:42 pm »
Okay I've managed to get it to work...

Here's what I did...

Download the SFML source code. Unpack it. Navigate to the root directory of the unzipped source code.

vim ./SFML/src/SFML/Graphics/CMakeLists.txt

Find the line on about line 149 -ish... yours may be different, since this is line 149 AFTER I made changes... which reads:

149 # ImageLoader.cpp must be compiled with the -fno-strict-aliasing
150 # when gcc is used; otherwise saving PNGs may crash in stb_image_write
151 if(SFML_COMPILER_GCC)
152     set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
153 endif()


Add the following lines BELOW

156 if(SFML_COMPILER_GCC AND BUILD_SHARED_LIBS)
157     message(WARNING "Applying workaround for https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899")
158     list(APPEND GRAPHICS_EXT_LIBS "-lgcc_s -lgcc")
159 endif()


Then cd to root dir of unpacked source

cmake .
make all
sudo make install

 

anything