mitsuba-renderer / nanogui

Minimalistic C++/Python GUI library for OpenGL, GLES2/3, Metal, and WebAssembly/WebGL
Other
1.57k stars 196 forks source link

Build problems #25

Open starseeker opened 4 years ago

starseeker commented 4 years ago

Hi! Seeing the following errors when trying a straight compile on Ubuntu with GCC 9.2.1:

[ 69%] Linking CXX executable example3 /usr/bin/ld: /tmp/example3.AIsY20.ltrans0.ltrans.o: undefined reference to symbol 'glViewport' /usr/bin/ld: /lib/x86_64-linux-gnu/libGL.so.1: error adding symbols: DSO missing from command line

bcumming commented 4 years ago

I have the same issue on Arch Linux. Note that the other examples build, and it is only example3 that fails this way. Here is the full compile line and error message:

/usr/bin/c++  -fvisibility=hidden  -Wall -Wextra -std=c++17 -flto -fno-fat-lto-objects -O3 -DNDEBUG  -lX11 -flto -rdynamic CMakeFiles/example3.dir/src/example3.cpp.o  -o example3  -Wl,-rpath,/home/bcumming/software/github/nanogui/build libnanogui.so 
/usr/bin/ld: libnanogui.so: undefined reference to symbol 'glViewport'
/usr/bin/ld: /usr/lib/libGL.so.1: error adding symbols: DSO missing from command line

This example makes a call to glViewport:

https://github.com/mitsuba-renderer/nanogui/blob/master/src/example3.cpp#L107

This can be fixed by manually adding -lGL to the end of the compilation line (after example3.cpp.o).

theHamsta commented 4 years ago

Having the same problem. Additionally when I want to use nanogui as a dependency in a own project I have in addition to linking to libnanogui.so also to manually build all OpenGL specific classes to avoid having undefined references: nanogui/src/window.cpp nanogui/src/screen.cpp nanogui/src/renderpass_gl.cpp nanogui/src/shader.cpp nanogui/src/shader_gl.cpp nanogui/src/texture_gl.cpp

This was not the case with same setup when I was using this project one month earlier.

Mandarancio commented 4 years ago

Same problem also with Fedora 32, the building stop at the linking of the example 3:

[ 70%] Linking CXX executable example3
/usr/bin/ld: libnanogui.so: undefined reference to symbol 'glViewport'
/usr/bin/ld: /usr/lib64/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/example3.dir/build.make:105: example3] Error 1
make[1]: *** [CMakeFiles/Makefile2:261: CMakeFiles/example3.dir/all] Error 2
make: *** [Makefile:150: all] Error 2

The built examples (1 and 2) froze once launched without any error message as well.

ChillGonzales commented 3 years ago

@theHamsta I am running into the same issue when trying to incorporate it in my project. Can you expand on how to manually build the OpenGL specific classes to fix this problem? 🙏

theHamsta commented 3 years ago

I added the respective file to this list: https://github.com/mitsuba-renderer/nanogui/blob/0146a88b2214cd5c5c29e6dfa8d3d3d0e9ab6d9d/CMakeLists.txt#L378 or I added them to my project (don't remember). Probably the are supposed to be added by ${NANOGUI_EXTRA}