make error /usr/bin/ld cannot find -lGL

I am trying to do classification from jetson-inference (jetson-inference/imagenet-example-2.md at master · dusty-nv/jetson-inference · GitHub) but using the camera. During make,it builds at 100% but before completing it gives this error " make error /usr/bin/ld cannot find -lGL ". I think its from Opengl but not sure though how to get rid of it.
Below is my CMakeLists file:-

cmake_minimum_required(VERSION 2.8)
project(camera)

find_package(jetson-utils)
find_package(jetson-inference)
find_package(PkgConfig REQUIRED)

pkg_search_module(GST REQUIRED gstreamer-1.0>=1.4
gstreamer-sdp-1.0>=1.4
gstreamer-video-1.0>=1.4
gstreamer-app-1.0>=1.4)

find_package(CUDA)
find_package(Qt4)

include(${QT_USE_FILE})
include_directories(/usr/include/gstreamer-1.0 /usr/lib/aarch64-linux-gnu/gstreamer-1.0/include /usr/include/glib-2.0 /usr/include/libxml2 /usr/lib/aarch64-linux-gnu/glib-2.0/include/)
add_definitions(${QT_DEFINITIONS})

cuda_add_executable(camera camera.cpp)

link my-recognition to jetson-inference library

target_link_libraries(camera jetson-inference)

Hi,

Have you installed the library?

https://github.com/dusty-nv/jetson-inference/blob/master/CMakePreBuild.sh#L18

sudo apt-get install -y libqt4-dev qt4-dev-tools libglew-dev glew-utils libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libglib2.0-dev

Thanks.

Hello AastaLL,
I think all the libraries were install when i build the jetson-inference but i executed the command anyway and the result is below:

nvidia@nvidia:~/Desktop/imagenet-camera/build$ sudo apt-get install -y libqt4-dev qt4-dev-tools libglew-dev glew-utils libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libglib2.0-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
glew-utils is already the newest version (2.0.0-5).
libglew-dev is already the newest version (2.0.0-5).
libqt4-dev is already the newest version (4:4.8.7+dfsg-7ubuntu1).
qt4-dev-tools is already the newest version (4:4.8.7+dfsg-7ubuntu1).
libglib2.0-dev is already the newest version (2.56.4-0ubuntu0.18.04.2).
libgstreamer-plugins-base1.0-dev is already the newest version (1.14.1-1ubuntu1~ubuntu18.04.2).
libgstreamer1.0-dev is already the newest version (1.14.1-1~ubuntu18.04.2).
0 upgraded, 0 newly installed, 0 to remove and 175 not upgraded.

nvidia@nvidia:~/Desktop/imagenet-camera/build$ sudo make
[ 50%] Linking CXX executable camera
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
CMakeFiles/camera.dir/build.make:110: recipe for target ‘camera’ failed
make[2]: *** [camera] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/camera.dir/all’ failed
make[1]: *** [CMakeFiles/camera.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2

I found the problem. the file in /usr/lib/aarch64-linux-gnu/libGL.so had a broken link.

So i fixed the link with the command

sudo ln -sfn libGL.so.1.0.0 libGL.so

Before solving :
ls -ll /usr/lib/aarch64-linux-gnu/libGL.so*
lrwxrwxrwx 1 root root 41 Mai 16 15:29 /usr/lib/aarch64-linux-gnu/libGL.so → /usr/lib/aarch64-linux-gnu/tegra/libGL.so (This line was red due to broken link)
lrwxrwxrwx 1 root root 14 Aug 15 2018 /usr/lib/aarch64-linux-gnu/libGL.so.1 → libGL.so.1.0.0
-rw-r–r-- 1 root root 972968 Aug 15 2018 /usr/lib/aarch64-linux-gnu/libGL.so.1.0.0

After Solving:
ls -ll /usr/lib/aarch64-linux-gnu/libGL.so*
lrwxrwxrwx 1 root root 14 Mai 16 15:36 /usr/lib/aarch64-linux-gnu/libGL.so → libGL.so.1.0.0
lrwxrwxrwx 1 root root 14 Aug 15 2018 /usr/lib/aarch64-linux-gnu/libGL.so.1 → libGL.so.1.0.0
-rw-r–r-- 1 root root 972968 Aug 15 2018 /usr/lib/aarch64-linux-gnu/libGL.so.1.0.0

Hope it helps someone having a broken link with libGL.so

Hi,

Thanks for the feedback.
Good to know this : )

There are some rare cases where another package might install the Mesa version of libGL, but the NVIDIA version is required. When that happens, or if you wish to test, see if all shows as “ok” from:

sha1sum -c /etc/nv_tegra_release

Prior to fixing the link there is a good chance that sha1sum would have mentioned a failure. Since the file “/etc/nv_tegra_release” contains all of the file paths being checked it makes a nice reference if you ever forget where the libGL.so is.

1 Like