*

Law

  • *
  • 34
    • View Profile
Cmake problem
« on: 09 August 2014, 22:55:25 »
Hello, I followed the instructions regarding the installation via cmake, and this is what I bump into:

Code: [Select]
[...]
[ 84%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/ChatBox.cpp.o
[ 87%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/MessageBox.cpp.o
[ 89%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Knob.cpp.o
Linking CXX shared library ../../lib/libtgui.so
[ 89%] Built target tgui
Scanning dependencies of target FormBuilder
[ 92%] [ 94%] [ 97%] [100%] Building CXX object src/TGUI/FormBuilder/CMakeFiles/FormBuilder.dir/Form.cpp.o
Building CXX object src/TGUI/FormBuilder/CMakeFiles/FormBuilder.dir/main.cpp.o
Building CXX object src/TGUI/FormBuilder/CMakeFiles/FormBuilder.dir/FormBuilder.cpp.o
Building CXX object src/TGUI/FormBuilder/CMakeFiles/FormBuilder.dir/MenuBar.cpp.o
Linking CXX executable FormBuilder
../../../lib/libtgui.so.0.6.4: undefined reference to `sf::Image::~Image()'
collect2: error: ld returned 1 exit status
make[2]: *** [src/TGUI/FormBuilder/FormBuilder] Error 1
make[1]: *** [src/TGUI/FormBuilder/CMakeFiles/FormBuilder.dir/all] Error 2
make: *** [all] Error 2

How do I sort this out ? Or maybe this is a minor problem that doesn't need to be fixed ?

Thank you.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #1 on: 09 August 2014, 23:07:06 »
I have never encountered this problem before.
I even just tried with the latest tgui version and with both the latest sfml and with sfml 2.1 and I don't get this error.

Anything you might have done special (running something else than "cmake .." or having a different sfml version)?
Can you draw something on the screen with just sfml?

The library seems to build fine, so if you run "cmake -DTGUI_BUILD_FORM_BUILDER=FALSE .." instead then it will work, you just won't have the form builder (but you can run the provided exe with wine instead of compiling the native one if really necessary). I just fear that you are going to run into similar problems when using tgui in your project.

Perhaps you could also try re-installing sfml, it looks like a very strange error.

*

Law

  • *
  • 34
    • View Profile
Re: Cmake problem
« Reply #2 on: 09 August 2014, 23:17:33 »
Thank you for the fast reply.

I entered

Code: [Select]
sudo make install -j6
again but this time, it goes directly to [89%] and lists the same errors. I don't think I ever did anything special, I have the latest SFML version and I could use it to draw moving cards in a RenderWindow already.

I entered

Code: [Select]
cmake -DTGUI_BUILD_FORM_BUILDER=FALSE ..
and I got

Code: [Select]
lol@Gaara:~/Documents/TGUI-0.6$ cmake -DTGUI_BUILD_FORM_BUILDER=FALSE ..
CMake Error: The source directory "/home/lol/Documents" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

So I had to remove the ".." and try again. After that, everything went perfectly.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #3 on: 09 August 2014, 23:32:59 »
The ".." assumes that you are running cmake from a build folder, to avoid that a lot of cmake cache files are created inside the tgui folder.
I didn't care about this in the tutorial since it doesn't matter for the tgui users, but I'm used to using a build folder to avoid these cmake files showing up in git.

Quote
everything went perfectly
I hope it stays that way. Because that error indicates that a function is missing from libsfml-graphics.so. But if it wouldn't be linking to it at all then you would get tons of these undefined reference errors.

You could possibly check if the file really misses the function or not.
Running this in the terminal should give a small list of functions and _ZN2sf5ImageD1Ev and _ZN2sf5ImageD2Ev should be in that list (with a T in front of them).
Code: [Select]
nm /usr/local/lib/libsfml-graphics.so | grep sf5Image

*

Law

  • *
  • 34
    • View Profile
Re: Cmake problem
« Reply #4 on: 09 August 2014, 23:42:50 »
My .so files are in /usr/lib/x86_64-linux-gnu/, not in /usr/local/lib/, so I changed things a bit.

Here is what I entered and got :

Code: [Select]
lol@Gaara:~/Documents/TGUI-0.6$ nm /usr/local/lib/libsfml-graphics.so | grep sf5Image
nm: '/usr/local/lib/libsfml-graphics.so': No such file
lol@Gaara:~/Documents/TGUI-0.6$ nm /usr/lib/x86_64-linux-gnu/libsfml-graphics.so | grep sf5Image
nm: /usr/lib/x86_64-linux-gnu/libsfml-graphics.so: no symbols
lol@Gaara:~/Documents/TGUI-0.6$ nm /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2 | grep sf5Image
nm: /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2: no symbols
lol@Gaara:~/Documents/TGUI-0.6$ nm /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2.1 | grep sf5Image
nm: /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2.1: no symbols

:/

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #5 on: 09 August 2014, 23:48:38 »
Apparently you need to use "nm --dynamic" instead of just "nm", although I didn't need it on my system (but I'm using arch and not debian/ubuntu like you). (based on https://lists.debian.org/debian-user/1997/11/msg00428.html)

I'm not even sure if there is anything interesting to find in these so files or not. I'm just guessing random stuff because I don't understand why it can complain about just one missing symbol.

Edit: running "nm --dynamic /usr/local/lib/libsfml-graphics.so -C | grep sf::Image::~Image" might be more clear and should return 2 lines.
« Last Edit: 09 August 2014, 23:53:02 by texus »

*

Law

  • *
  • 34
    • View Profile
Re: Cmake problem
« Reply #6 on: 09 August 2014, 23:57:58 »
Okay I added the "--dynamic" and got a few results. I found

Code: [Select]
[...]
0000000000010de0 T _ZN2sf5ImageC1Ev
0000000000010de0 T _ZN2sf5ImageC2Ev
[...]

but not _ZN2sf5ImageD1Ev and _ZN2sf5ImageD2Ev like you said.

I then searched for "sf::Image::~Image" like you suggested and got 0 results :

Code: [Select]
lol@Gaara:~/Documents/TGUI-0.6$ nm --dynamic /usr/lib/x86_64-linux-gnu/libsfml-graphics.so | grep sf::Image::~Image
lol@Gaara:~/Documents/TGUI-0.6$ nm --dynamic /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2 | grep sf::Image::~Image
lol@Gaara:~/Documents/TGUI-0.6$ nm --dynamic /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2.1 | grep sf::Image::~Image

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #7 on: 10 August 2014, 00:04:58 »
Then your libsfml-graphics.so is indeed missing a destructor for the Image class. I would think you are also going to have problems with just using sfml without tgui, since sf::Image::~Image just isn't there. The lines with the C instead of the D are the constructors of the class.

If you don't get any further problems then you can continue like this, but now we know that the problem lies with sfml. I'm not sure how you installed it, but if you get further trouble then you should try to re-install it or install it in another way.

*

Law

  • *
  • 34
    • View Profile
Re: Cmake problem
« Reply #8 on: 10 August 2014, 00:08:25 »
Okay thank you for your help :)

I will ask for more help in the appropriate forum (SFML's forum), I'm sure this will be fixed, eventually. Thanks again for your time, I look forward to using TGUI  :D

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #9 on: 10 August 2014, 00:08:58 »
Wait before you ask on the sfml forum, I just figured something out.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #10 on: 10 August 2014, 00:12:52 »
You said you have the latest sfml version installed, but I don't think you have.

SFML 2.1 has no destructor in the Image class, this was added later.
So it seems like TGUI has been linked to a later version of sfml, while the library you are looking at is from SFML 2.1.
Do you perhaps have multiple versions on your pc?

I would uninstall everything from sfml that you have and then really install the latest version (install git if you don't have it yet).
Code: [Select]
git clone https://github.com/LaurentGomila/SFML
mkdir SFML/build
cd SFML/build
cmake ..
make -j4
sudo make install

Then try installing tgui again.
Code: [Select]
git clone https://github.com/texus/TGUI
mkdir TGUI/build
cd TGUI/build
cmake ..
make -j4
sudo make install
« Last Edit: 10 August 2014, 00:17:24 by texus »

*

Law

  • *
  • 34
    • View Profile
Re: Cmake problem
« Reply #11 on: 10 August 2014, 00:20:22 »
Will do asap but how do I uninstall SFML safely?

At first I thought it shouldn't be a problem and I *should* directly install with git without any problems, but when I did:

Code: [Select]
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
CMake Error at src/SFML/Window/CMakeLists.txt:188 (message):
  Xrandr library not found


-- Configuring incomplete, errors occurred!
See also "/home/lol/SFML/build/CMakeFiles/CMakeOutput.log".

So how do I do?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #12 on: 10 August 2014, 00:24:44 »
Quote
how do I uninstall SFML safely?
By doing the opposite of how you installed it. I have no idea how you installed it. Perhaps you used apt-get and then you uninstall it with "apt-get remove sfml" or "apt-get remove sfml-dev" or something similar.

Quote
So how do I do?
The latest version of sfml depends on the xrandr library which is missing from your system (I guess sfml 2.1 didn't use xrandr yet).
I think you install it with "sudo apt-get install xrandr" but it has been a while since I have used ubuntu.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Cmake problem
« Reply #13 on: 10 August 2014, 00:28:45 »
I wonder, did you test sfml before you tried to install tgui?
XRandr has always been a dependency of sfml, and sfml shouldn't be able to function without it.

If you installed sfml by just copying the files to the lib folder manually then removing them can also be done by removing them manually. But if you used apt-get to install it then you must also use apt-get to remove it.

This should install xrandr:
Code: [Select]
sudo apt-get install libxrandr-dev
« Last Edit: 10 August 2014, 00:30:17 by texus »

*

Law

  • *
  • 34
    • View Profile
Re: Cmake problem
« Reply #14 on: 10 August 2014, 00:42:36 »
Okay, I installed muon so that I could safely uninstall all SFML packages.
After that, I installed xrandr like you suggested.
Then I started over and after entering "cmake ..", I bumped into this :

Code: [Select]
[...]
-- Looking for shmat - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so 
-- UDev not found.
-- UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include
--       currently found includes: UDEV_INCLUDE_DIR-NOTFOUND
-- UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib
--       currently found libs: UDEV_LIBRARIES-NOTFOUND
CMake Error at cmake/Modules/FindUDev.cmake:49 (MESSAGE):
  Could not find UDev library
Call Stack (most recent call first):
  src/SFML/Window/CMakeLists.txt:203 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/lol/SFML/build/CMakeFiles/CMakeOutput.log".