lcm-proj / lcm

Lightweight Communications and Marshalling
GNU Lesser General Public License v2.1
944 stars 385 forks source link

liblcm-test: add GLib2::glib to target_link_libraries #444

Closed ihilt closed 1 year ago

ihilt commented 1 year ago

Observed using the Linaro SDK. GLib was also cross-compiled.

The error:

/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/7.5.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libglib-2.0.so.0, needed by ../lcm/liblcm.so.1.5.0, not found (try using -rpath or -rpath-link)
../lcm/liblcm.so.1.5.0: undefined reference to `g_list_delete_link'
../lcm/liblcm.so.1.5.0: undefined reference to `g_free'
...

Toolchain file:

set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_PROCESSOR "arm")
set(CMAKE_SIZEOF_VOID_P "4")
set(CMAKE_C_COMPILER "/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++")
set(GLIB2_GLIB_LIBRARY "/usr/local/arm-linux-gnueabihf/lib/libglib-2.0.so")
set(GLIB2_GLIB_INCLUDE_DIR "/usr/local/arm-linux-gnueabihf/include/glib-2.0")
set(GLIB2_GLIBCONFIG_INCLUDE_DIR "/usr/local/arm-linux-gnueabihf/lib/glib-2.0/include")
ihilt commented 1 year ago

I think this is a false alarm. Recompiling GLib seems to have fixed the problem.

nedlrichards commented 1 year ago

I had this same issue, which I fixed by changing the CMakeLists.txt as suggested. I tried simply recompiling GLib to no avail. I also ran into the same glib issue with the test-c-server. I avoided this with -DLCM_ENABLE_TESTS=OFF. In retrospect, I could have avoided this issue completely by using -DLCM_ENABLE_EXAMPLES=OFF as well.

tprk77 commented 1 year ago

The lcm target should be now be propagating the GLib2::glib dependency. But not too long ago, it didn't do this. My best guess is that there's some outdated stuff cached in your build directory. Did you do a clean build?