la1k / flyby

A satellite tracking program
GNU General Public License v2.0
39 stars 8 forks source link

Build error on Archlinux #78

Closed ivareri closed 6 years ago

ivareri commented 7 years ago

ld is unable to find libpredict on archlinux when it is installed to /usr/local/lib. ldconfig is able to find the library.

Can be solved by using find_library() in CMakeLists.txt

[slegge@bobbie build]$ ldconfig -p | grep predict
    libpredict.so.1 (libc6,x86-64) => /usr/local/lib64/libpredict.so.1
    libpredict.so (libc6,x86-64) => /usr/local/lib64/libpredict.so
[slegge@bobbie build]$ make
Scanning dependencies of target transponder_utility
[  4%] Building C object CMakeFiles/transponder_utility.dir/src/transponder_utility.c.o
[  8%] Building C object CMakeFiles/transponder_utility.dir/src/tle_db.c.o
[ 12%] Building C object CMakeFiles/transponder_utility.dir/src/transponder_db.c.o
[ 16%] Building C object CMakeFiles/transponder_utility.dir/src/string_array.c.o
[ 20%] Building C object CMakeFiles/transponder_utility.dir/src/xdg_basedirs.c.o
[ 25%] Building C object CMakeFiles/transponder_utility.dir/src/option_help.c.o
[ 29%] Linking C executable flyby-transponder-dbutil
/usr/bin/ld: cannot find -lpredict
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/transponder_utility.dir/build.make:225: flyby-transponder-dbutil] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/transponder_utility.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
thenorthcore commented 7 years ago

Might be partly solvable by using pkg-config see https://github.com/la1k/flyby/commit/2982b8d55c5cd88ff9d59c345c8268b508d1c6d0. Unfortunately, /usr/local/lib64/pkgconfig is not in the search path of stock pkg-config on Arch Linux (tested with Antergos). Corresponding libpredict related fix for the pkg-config file to work with Archs '/usr/local/lib64' issue can be found in https://github.com/la1k/libpredict/pull/81.

thenorthcore commented 6 years ago

looks like pkg-config is looking for .pc files related to a default path but can be augmented with the PKG_CONFIG_PATH environment variable:

PKG_CONFIG_PATH A colon-separated (on Windows, semicolon-separated) list of directories to search for .pc files. The default directory will always be searched after searching the path; the default is libdir/pkgconfig:datadir/pkgconfig where libdir is the libdir for pkg-config and datadir is the datadir for pkg-config when it was installed.

so an export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig before you call cmake in your build directory will resolve the problem once https://github.com/la1k/libpredict/issues/82 is fixed in libpredict.

bjorgan commented 6 years ago

Mainly an archlinux path problem in that they have removed /usr/local/* from their paths but still let CMAKE_INSTALL_PREFIX point to /usr/local/. Since https://github.com/la1k/libpredict/issues/82 is closed, and flyby now uses pkgconfig, it should at least be easier now to work around the issue without having to install directly into /usr/.

Would recommend using PKG_CONFIG_PATH=[path to libpredict install dir/pkgconfig] cmake .., which will make the PKG_CONFIG_PATH variable local to this specific cmake instance. CMake will then set all relevant paths in CMakeCache.txt and everything will be fine and dandy.

Pkgconfig also seems to make it link against the library files in a very magic way, so that you don't get linker errors when libpredict.so-files are located in non-standard paths, and don't have to care about LD_PRELOAD-variables. Closing this for now.