JoeyDeVries / LearnOpenGL

Code repository of all OpenGL chapters from the book and its accompanying website https://learnopengl.com
https://learnopengl.com
Other
11.06k stars 2.8k forks source link

Some compiling problems under Ubuntu 14.04 #9

Closed eulersson closed 9 years ago

eulersson commented 9 years ago

I am getting some weird errors complaining about 'XConvertSelection' when I run the make, this is what the output looks like:

Linking CXX executable bin/2.lighting/1.colors
/usr/bin/ld: /usr/local/lib/libglfw3.a(x11_window.c.o): undefined reference to symbol 'XConvertSelection'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [bin/2.lighting/1.colors] Error 1
make[1]: *** [CMakeFiles/1.colors.dir/all] Error 2
make: *** [all] Error 2

Any idea on how to work around this? Thanks in advance.

JoeyDeVries commented 9 years ago

I'm not sure as I have no experience building the samples on Linux (one of the readers helped me out on the CMakeFile linux sections). Does it only occur on the color demo or all demo's as then I'd say you probably didn't correctly install glfw3?

Kind regards,

Ramon Blanquer schreef op 11-5-2015 om 23:48:

I am getting some weird errors complaining about 'XConvertSelection' when I run the |make|, this is what the output looks like:

|Linking CXX executable bin/2.lighting/1.colors /usr/bin/ld: /usr/local/lib/libglfw3.a(x11_window.c.o): undefined reference to symbol 'XConvertSelection' //usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make[2]: * [bin/2.lighting/1.colors] Error 1 make[1]: * [CMakeFiles/1.colors.dir/all] Error 2 make: *\ [all] Error 2

Any idea on how to work around this? Thanks in advance.

— Reply to this email directly or view it on GitHub https://github.com/JoeyDeVries/LearnOpenGL/issues/9.

eulersson commented 9 years ago

@JoeyDeVries hello thanks for the answer. I can use glfw if I create my own projects, but I don't know why cmake does something weird with the paths. I will try to uninstall glfw and reinstall it just using sudo apt-get and see what happens. Thanks! :)

JoeyDeVries commented 9 years ago

Alright, let me know if it works. If it still doesn't work you can try to ask @zwookie if he understands what's going on (he knows a lot more about linux compilation than I do ;))

zmertens commented 9 years ago

Hm, that's weird as I'm also using Ubuntu 14.04 and can't seem to duplicate the issue. I did stumble upon this Stack Overflow post. Can you give that a shot @docwhite, try moving the order of libraries set in the Unix block in the CMakeLists.txt file and see if that works.

stephane-lb commented 9 years ago

Hi guys, can I suggest to you to test with the Mac version I just finished. It works on an Archlinux today, do not have an Ubuntu here, if needed I will virtualise one, let me know ;-)

eulersson commented 9 years ago

@stephane-lb hey! I tried it but it did not work... CMake 3.0.2 or higher is required. You are running version 2.8.12.2 I tried to update cmake but it tells me that I am currently on the newest version. I am confused. In launchpad CMake is a newer version... I have 2.8.12. Sorry I am a Linux noob when it comes to these things. Do I have to change ppa's or anything? @zwookie I tried to change the order of the libraries but same thing happens mate :-( Nevermind, I will switch to CentOS soon. I don't want to spend your time with these... but it is so weird what I am getting. Thanks again. :dancers: :smile:

stephane-lb commented 9 years ago

@docwhite Hey ! I did not need make 3.0, so I updated with the 2.8, you should be able to test again. Hope it will works. let me know.

eulersson commented 9 years ago

@stephane-lb thanks it works now :D but after making it what should I do? I can just see shaders under the build/bin/ subdir

stephane-lb commented 9 years ago

@docwhite did you make ? ( after cmake ../. )

eulersson commented 9 years ago

@stephane-lb mmm... I was wrong. I am getting errors during the cmake execution.

-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:16 (add_subdirectory):
  The source directory

    /home/doc/LOGL/LearnOpenGL/external/glew-cmake

  does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:23 (add_subdirectory):
  The source directory

    /home/doc/LOGL/LearnOpenGL/external/glfw

  does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:32 (add_subdirectory):
  The source directory

    /home/doc/LOGL/LearnOpenGL/external/assimp

  does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:36 (add_subdirectory):
  The source directory

    /home/doc/LOGL/LearnOpenGL/external/SOIL

  does not contain a CMakeLists.txt file.

-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so  
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring incomplete, errors occurred!
See also "/home/doc/LOGL/LearnOpenGL/build/CMakeFiles/CMakeOutput.log".
See also "/home/doc/LOGL/LearnOpenGL/build/CMakeFiles/CMakeError.log".
eulersson commented 9 years ago

Sorry I have no clue on CMake files. :-( I can't really help much

stephane-lb commented 9 years ago

No worries. Looks like you did not follow the instruction :

git clone --recursive [https://github.com/stephane-lb/LearnOpenGL.git
cd LearnOpenGL
mkdir build
cd build
cmake ../.
make -j8

So you did not initialise the submodules. The thing that you can do know is :

cd LearnOpenGL
git submodule update --init --recursive
cd build
rm -fr * 
cmake ../.
make -j8

P.S: just got an access to an ubuntu 14.04, and trying to compile have the same kind of error than you :

/usr/bin/ld: external/glfw/src/libglfw3.a(x11_init.c.o): référence au symbole non défini «XF86VidModeQueryExtension»
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libXxf86vm.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
eulersson commented 9 years ago

@stephane-lb Oh thats why! I just did clone, non recursively haha. It works now thanks! But why did you do all the cmake thing? To install the libraries to someone who might not have them? If I want to run an example what should I do exactly? Thanks for your patience.

stephane-lb commented 9 years ago

It is a choice, for my point of view I still prefer to give all the libraries with my project. By Doing that I do not ask anyone to install something that I don't know. That's why I use a lot of submodules

I am surprised that It works ( because I had to change couple of thing to compile in Ubuntu and I have not pushed yet), however to run an example you could test:

cd build
./bin/1.getting_started/7.camera 
stephane-lb commented 9 years ago

Update : Just finished to fix this, works on Ubuntu 14.04

eulersson commented 9 years ago

IT WORKS! Thanks very much indeed @stephane-lb !!! :dancer:

zmertens commented 9 years ago

@stephane-lb did you have to change anything to the CMake to get it to build? Was the issue resolved by getting the libraries a certain way?

stephane-lb commented 9 years ago

@zwooie Yes, because blew is used as a static library order matter. This is the order I use :+1:

set(LIBS glfw)
list(APPEND LIBS libglew_static)
list(APPEND LIBS SOIL_Static)
list(APPEND LIBS assimp)
find_package(OpenGL REQUIRED)
list(APPEND LIBS ${OPENGL_gl_LIBRARY}) # setting LIBS for the first time
add_definitions(${OPENGL_DEFINITIONS})
find_package(X11 REQUIRED)
list(APPEND LIBS ${X11_Xrandr_LIB} ${X11_Xxf86vm_LIB} ${X11_Xinerama_LIB} ${X11_Xi_LIB} ${X11_Xcursor_LIB})
find_package(Threads REQUIRED)
list(APPEND LIBS ${CMAKE_THREAD_LIBS_INIT})
zmertens commented 9 years ago

@stephane-lb I still haven't been able to replicate the issue, but I'll take your word for it. Can you make a pull request and we can test it?

stephane-lb commented 9 years ago

Sure, I will do it end of the week !

zmertens commented 9 years ago

So, I've just recently switched to Linux Mint 17.2 and I've run into this issue. Currently researching possible fixes. I'll post an update once I find something.

EDIT: Think I found a solution. I have made a pull request #14 for it. @docwhite and @stephane-lb can you guys test it out if you get a chance sometime?

EDIT2: Tested #14 on Ubuntu 14.04 and doesn't appear to break anything!

JoeyDeVries commented 9 years ago

Alright! I'll merge it into the current repository and do a few tests myself later this week; if everything runs oké I'll close the issue :D

JoeyDeVries commented 9 years ago

It (still) works fine on my machines and so far no negative response so I'm closing the issue. Thanks for the fixes!