navit-gps / navit

The open source (GPL v2) turn-by-turn navigation software for many OS
http://www.navit-project.org
Other
549 stars 173 forks source link

Bug: error while loading shared libraries: libfib.so #629

Open ihuguet opened 6 years ago

ihuguet commented 6 years ago

I get this error when installed navit in a custom device (using Buildroot).

Doing find / -name libfib.so I get that the library is located in /usr/lib/navit/libfib.so. The problem is that the directory /usr/lib/navit is not in the shared libraries search path, /usr/lib is.

Moving libfib.so to /usr/lib navit runs fine.

I don't have problems with other shared libraries like plugins, support, etc. I guess that they are loaded in a different way.

Possible solutions:

Note: this patch should work, but I haven't been able to test it because Buildroot seems to be removing the RPATH property from the executable.

diff -Naur navit-v0.5.1/navit/CMakeLists.txt navit-v0.5.1-2/navit/CMakeLists.txt
--- navit-v0.5.1/navit/CMakeLists.txt   2018-06-27 14:54:05.808344052 +0200
+++ navit-v0.5.1-2/navit/CMakeLists.txt 2018-06-27 14:40:37.000000000 +0200
@@ -81,6 +81,7 @@
    endif()
    add_executable(navit ${NAVIT_START_SRC})
    target_link_libraries (navit ${NAVIT_LIBNAME})
+   set_target_properties(navit PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIB_DIR})
    if(DEFINED NAVIT_BINARY)
       set_target_properties(navit PROPERTIES OUTPUT_NAME ${NAVIT_BINARY})
    endif(DEFINED NAVIT_BINARY)
aerostitch commented 6 years ago

Hi @naggety, Thanks for reporting this. Which version are you using? There has been a PR (#574) since last release to fix the lib path when overwriting LIB_DIR. Do you overwrite your LIB_DIR? Thanks Joseph

ihuguet commented 6 years ago

Hi. I'm using version 0.5.1. I can't check now but I think this is after the PR you say.

El 27 jun. 2018 4:09 p. m., Joseph Herlant notifications@github.com escribió:

Hi @naggetyhttps://github.com/naggety, Thanks for reporting this. Which version are you using? There has been a PR (#574https://github.com/navit-gps/navit/pull/574) since last release to fix the lib path when overwriting LIB_DIR. Do you overwrite your LIB_DIR? Thanks Joseph

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/navit-gps/navit/issues/629#issuecomment-400684959, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADWWv7XTew1qwEpRabP8UYWrfp3U9fHbks5uA5IDgaJpZM4U5waQ.

aerostitch commented 6 years ago

That's unfortunately not the case. Do you set the $LIB_DIR in your environment at all?

ihuguet commented 6 years ago

I don't set LIBDIR nor LIB_DIR at all. The PR is not applied in v0.5.1, as you said, but since I'm not setting LIBDIR nor LIB_DIR, I think the PR wouldn't change anything for me.

I've tried with trunk version and I have the same problem.

It wouldn't be correct to install libfib.so to ${CMAKE_INSTALL_PREFIX}/${LIBDIR}, as I said, because LIBDIR could be undefined. We should find another way of installing it into a system default libs dir.

Regarding the other solution (adding /usr/lib/navit to the executable rpath) I have finally tested it and it works.

ihuguet commented 6 years ago

I confirm again that the patch of my first message fix the issue for me. Is there a better way to fix this? Who can check if this is OK building for other systems, other configs...?

aerostitch commented 6 years ago

I was trying to reproduce the issue with buildroot. Could you provide the configuratuion you're using please (target etc) so that we can check why it's a problem? At least architecture, OS, variables please. Thanks

ihuguet commented 6 years ago

Buildroot version: 2017.11.2 Target processor: Allwinner A20 (ARMv7, 32 bits) Target OS: custom Linux system, with sunxi-linux kernel (version 3.4.113) Navit config variables: -DSAMPLE_MAP=0 -Dgraphics/gtk_drawing_area=1 -DDISABLE_QT=1 -Dgraphics/qt5=0 -Dvehicle/qt5=0 -Dvehicle/gpsd=1

I attach my navit package and my defconfig file. You can apply the defconfig with make BR_DEFCONFIG=/path/to/defconfig/file defconfig, but note that you cannot use it directly because you don't have some files like my board overlays, etc. In navit package there is a patch file that it's just the patch of my first message to solve this issue.

defconfig.txt

navit.zip

aerostitch commented 6 years ago

@naggety sorry for the late reply. Your patch looks good. Do you want me to do a PR for it or do you want to do it?

Thanks Joseph

pgrandin commented 6 years ago

This is weird, using my buildroot setup the file does end up in output/target/usr/lib/libfib.so which seems correct. We need to dig.

jkoan commented 6 years ago

Hi @pgrandin and @naggety , the difference between your two navit.mk Files is that @pgrandin is setting -DLIBDIR=/usr/lib but @naggety commented out this. Now i am wondering why.

ihuguet commented 6 years ago

@jkoan: I used @pgrandin package in the past, but with more recent versions of navit it stopped working if using that define. I think that it is because some changes made to cmake scripts regarding LIBDIR and LIB_DIR variables, but I don't know it for sure.

@pgrandin: as far as I can see, installation of libfib is done from navit/fib-1.1/CMakeLists.txt. I don't know why it is installed to /usr/lib in your case and /usr/lib/navit in my case. I supose that you have tried with recent versions of buildroot and navit, right?

aerostitch commented 6 years ago

@naggety this issue was a regression introduced by #215 and fixed in #574.

It basically shows an issue when LIBDIR was set to a value like /usr/lib, before #215 it was installing everything in /usr/lib/navit, after #215 it was installing things in /usr/lib and #574 restored the behavior for that specific use case of installing in /usr/lib/navit.

So if you look at https://github.com/navit-gps/navit/blob/trunk/navit/fib-1.1/CMakeLists.txt it installs libfib.so using the supportlib_add_library macro defined at: https://github.com/navit-gps/navit/blob/trunk/cmake/navit_macros.cmake#L78 The destination is defined as DESTINATION ${LIB_DIR}/${${LIB_NAME}_TYPE} Now the content of LIB_DIR is defined in https://github.com/navit-gps/navit/blob/trunk/CMakeLists.txt#L44 which is the part modified with #574

@pgrandin @naggety can you retry both with the version 5.3 and let me know where is libfib.so and where is libfont_freetype.so please?

My 2 cents is that in both cases it is supposed to be in output/target/usr/lib/navit/libfib.so

ihuguet commented 4 years ago

@aerostitch with v5.3 'libfib.so' is in '/usr/lib/navit' and 'libfont_freetype.so' in '/usr/lib/navit/font'.

However, being 'libfib.so' in '/usr/lib/navit' makes navit not achieving to start. I have to manually move it to '/usr/lib'

pgrandin commented 4 years ago

I am still seeing issues with this as well. I'll start building a table of my experiments so that we can track the issue

navit buildroot result
b0a8ef218ce94e47e863692757364cac7ceb6070 https://github.com/buildroot/buildroot/commit/650818fb3a6fb7b9bd9fcefabbc187c1bbe95e0a works [1]
589c11d03dbe07ec2cb063c198df76bd21e0e8af (v0.5.3) https://github.com/buildroot/buildroot/commit/650818fb3a6fb7b9bd9fcefabbc187c1bbe95e0a No plugins found. Is Navit installed correctly? [2]
7b4c8877aceec093c5fca9c7ad040b6eecc8059f https://github.com/buildroot/buildroot/commit/650818fb3a6fb7b9bd9fcefabbc187c1bbe95e0a error while loading shared libraries: libsupport_libpng.so [3]

[1] libs are installed like this :

/usr/lib/libfib.so
/usr/lib/navit/libfib.so
[...]
/usr/lib/libsupport_libpng.so
/usr/lib/navit/libsupport_libpng.so
[...]
/usr/lib/vehicle
/usr/lib/vehicle/libvehicle_socket.so
/usr/lib/vehicle/libvehicle_demo.so
/usr/lib/vehicle/libvehicle_file.so
/usr/lib/vehicle/libvehicle_serial.so
/usr/lib/vehicle/libvehicle_pipe.so
/usr/lib/vehicle/libvehicle_gpsd.so
/usr/lib/navit/vehicle
/usr/lib/navit/vehicle/libvehicle_socket.so
/usr/lib/navit/vehicle/libvehicle_demo.so
/usr/lib/navit/vehicle/libvehicle_file.so
/usr/lib/navit/vehicle/libvehicle_serial.so
/usr/lib/navit/vehicle/libvehicle_pipe.so
/usr/lib/navit/vehicle/libvehicle_gpsd.so

so basically twice

[2] libs are installed like this :

/usr/lib/navit/libfib.so
/usr/lib/libfib.so
# find /usr/lib -name 'libveh*'
/usr/lib/navit/vehicle/libvehicle_demo.so
/usr/lib/navit/vehicle/libvehicle_socket.so
/usr/lib/navit/vehicle/libvehicle_gpsd.so
/usr/lib/navit/vehicle/libvehicle_pipe.so
/usr/lib/navit/vehicle/libvehicle_file.so
/usr/lib/navit/vehicle/libvehicle_serial.so
/usr/lib/vehicle/libvehicle_demo.so
/usr/lib/vehicle/libvehicle_socket.so
/usr/lib/vehicle/libvehicle_gpsd.so
/usr/lib/vehicle/libvehicle_pipe.so
/usr/lib/vehicle/libvehicle_file.so
/usr/lib/vehicle/libvehicle_serial.so

[3] libs are installed like this :

/usr/lib/navit
/usr/lib/navit/libsupport_shapefile.so
/usr/lib/navit/libsupport_libpng.so
/usr/lib/navit/libfib.so
/usr/lib/navit/graphics
/usr/lib/navit/graphics/libgraphics_null.so
/usr/lib/navit/osd
/usr/lib/navit/osd/libosd_core.so
/usr/lib/navit/vehicle
/usr/lib/navit/vehicle/libvehicle_socket.so
/usr/lib/navit/vehicle/libvehicle_pipe.so
/usr/lib/navit/vehicle/libvehicle_serial.so
/usr/lib/navit/vehicle/libvehicle_gpsd.so
/usr/lib/navit/vehicle/libvehicle_demo.so
/usr/lib/navit/vehicle/libvehicle_file.so
/usr/lib/navit/gui
/usr/lib/navit/gui/libgui_internal.so
/usr/lib/navit/traffic
/usr/lib/navit/traffic/libtraffic_null.so
/usr/lib/navit/traffic/libtraffic_dummy.so
/usr/lib/navit/speech
/usr/lib/navit/speech/libspeech_cmdline.so
/usr/lib/navit/map
/usr/lib/navit/map/libmap_filter.so
/usr/lib/navit/map/libmap_textfile.so
/usr/lib/navit/map/libmap_shapefile.so
/usr/lib/navit/map/libmap_csv.so
/usr/lib/navit/map/libmap_mg.so
/usr/lib/navit/map/libmap_binfile.so

Copying the top-level libs to /usr/lib results in:

# cp /usr/lib/navit/*.so /usr/lib/
# navit
error:navit:plugins_init:Warning: No plugins found. Is Navit installed correctly?
Baggypants commented 2 years ago

I'm having the same issue with trying to build an rpm for fedora. The cmake install puts libfib.so in /usr/lib64/navit/libfib.so but navit can't find it unless I symlink it to /usr/lib64 this is on Fedora Rawhide aarch64.

l29ah commented 2 years ago

Got the same problem when packaging navit for Gentoo. https://patch-diff.githubusercontent.com/raw/navit-gps/navit/pull/647.patch (#647) fixed it.