[PATCH] kernelshark: Fix "undefined reference to `glutInit'" when using CMake 3.22.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When building with cmake 3.22.1, the build fails with the following
errors:

    /bin/ld: dataplot.cpp:(.text+0x17): undefined reference to `glutInit'
    /bin/ld: dataplot.cpp:(.text+0x62): undefined reference to `glutDisplayFunc'
    /bin/ld: dataplot.cpp:(.text+0x6d): undefined reference to `glutMainLoop'
    /bin/ld: ../../lib/libkshark-plot.so.2.0.2: undefined reference to `glutInitWindowPosition'
    /bin/ld: ../../lib/libkshark-plot.so.2.0.2: undefined reference to `glutInitDisplayMode'
    /bin/ld: ../../lib/libkshark-plot.so.2.0.2: undefined reference to `glutInitWindowSize'
    /bin/ld: ../../lib/libkshark-plot.so.2.0.2: undefined reference to `glutCreateWindow'
    /bin/ld: ../../lib/libkshark-plot.so.2.0.2: undefined reference to `glutSetOption'

The reason is this cmake commit:
https://gitlab.kitware.com/cmake/cmake/-/commit/f90d15458a9a98180fcc95158f2ab5d2b1ad3152,
which changes how the glut library is searched for. Specifically,
pkg-config is newly tried before other methods.

When pkg-config finds the library it doesn't set GLUT_LIBRARY variable
used by kernelshark, but only GLUT_LIBRARIES, as mentioned in the
official documentation:

    https://cmake.org/cmake/help/v3.22/module/FindGLUT.html

Therefore, we should switch to using the documented variable.

I also tested this change with CMake 3.21.2 (before the mentioned
commit) and it works.

Signed-off-by: Michal Sojka <michal.sojka@xxxxxxx>
---
 src/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index babb9c1..e4cf78f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -59,7 +59,7 @@ if (OPENGL_FOUND)
                                      KsPlugins.cpp)
 
     target_link_libraries(kshark-plot  kshark
-                                       ${GLUT_LIBRARY}
+                                       ${GLUT_LIBRARIES}
                                        ${OPENGL_LIBRARIES})
 
     set_target_properties(kshark-plot PROPERTIES  SUFFIX ".so.${KS_VERSION_STRING}")
-- 
2.34.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux