nanogui icon indicating copy to clipboard operation
nanogui copied to clipboard

Build problems

Open starseeker opened this issue 5 years ago • 5 comments

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

starseeker avatar Mar 08 '20 19:03 starseeker

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

bcumming avatar Mar 09 '20 16:03 bcumming

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.

theHamsta avatar Mar 16 '20 18:03 theHamsta

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.

Mandarancio avatar Jun 06 '20 19:06 Mandarancio

@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? 🙏

ChillGonzales avatar Feb 13 '21 20:02 ChillGonzales

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}

theHamsta avatar Feb 13 '21 21:02 theHamsta