Cmake problem

Started by Law, 09 August 2014, 22:55:25

Law

Hello, I followed the instructions regarding the installation via cmake, and this is what I bump into:

[...]
[ 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

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

Thank you for the fast reply.

I entered

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

cmake -DTGUI_BUILD_FORM_BUILDER=FALSE ..

and I got

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

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.

Quoteeverything 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).
nm /usr/local/lib/libsfml-graphics.so | grep sf5Image

Law

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 :

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

#5
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.

Law

Okay I added the "--dynamic" and got a few results. I found

[...]
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 :

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

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

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

Wait before you ask on the sfml forum, I just figured something out.

texus

#10
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).
git clone https://github.com/LaurentGomila/SFML
mkdir SFML/build
cd SFML/build
cmake ..
make -j4
sudo make install


Then try installing tgui again.
git clone https://github.com/texus/TGUI
mkdir TGUI/build
cd TGUI/build
cmake ..
make -j4
sudo make install

Law

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:

-- 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

Quotehow 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.

QuoteSo 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

#13
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:
sudo apt-get install libxrandr-dev

Law

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 :

[...]
-- 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".

texus

#15
Same thing: "Could not find UDev library".
Typical format in ubuntu is libXXX-dev, so again it is just "sudo apt-get install libudev-dev".

Edit: You might get errors for the other dependencies too:
    pthread
    opengl
    xlib
    xrandr
    freetype
    glew
    jpeg
    sndfile
    openal

You can look up the package name by searching for them on https://packages.ubuntu.com/, but like I said it is mostly called libXXX-dev.

Law

Yes I had to install a few packages, but I managed to find and install them all eventually.

Then I entered all the instructions you listed and they went fine (for both SFML and TGUI). I now have them both installed on my computer. I compiled a file of mine and it compiled with no error, just as usual. So I think my problem is solved.

Thanks a lot! I'm going to bed now^^ I should hope no problem will appear tomorrow :)