Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling fails when installed locally (cmake) #157

Open
zyzzyxdonta opened this issue Nov 15, 2019 · 0 comments
Open

Compiling fails when installed locally (cmake) #157

zyzzyxdonta opened this issue Nov 15, 2019 · 0 comments

Comments

@zyzzyxdonta
Copy link

zyzzyxdonta commented Nov 15, 2019

I include libconfig in my cmake project with find_package(libconfig++ REQUIRED) and target_link_libraries(${PROJECT_NAME} config++). Both on Archlinux and Fedora 31 this works fine. However on a remote machine to which I don't have root access, therefore only a local libconfig installation, linking fails with /usr/bin/ld: cannot find -lconfig++.

To install libconfig, I used the tarball from the project site, ran configure --prefix=$HOME/.local and make install and make test ran without a problem. Compiling my project works fine. I think the header files are found due to spdlog also being installed locally. When spdlog is not installed, the libconfig headers aren't found, either. So I guess there must be something wrong in the cmake configuration.

Printing all cmake variables shows:

...
-- CMAKE_SYSTEM_PREFIX_PATH=...;/home/<name>/.local;...
...
-- CONFIG_FILES=/home/<name>/.local/lib/cmake/spdlog/spdlogConfigTargets-release.cmake # no libconfig here
...
-- libconfig++_CONFIG=/home/<name>/.local/lib/cmake/libconfig++/libconfig++Config.cmake
-- libconfig++_CONSIDERED_CONFIGS=/home/<name>/.local/lib/cmake/libconfig++/libconfig++Config.cmake
-- libconfig++_CONSIDERED_VERSIONS=unknown
-- libconfig++_DIR=/home/<name>/.local/lib/cmake/libconfig++
-- libconfig++_FOUND=1
-- libconfig++_VERSION_COUNT=0
-- libconfig++_VERSION_MAJOR=0
-- libconfig++_VERSION_MINOR=0
-- libconfig++_VERSION_PATCH=0
-- libconfig++_VERSION_TWEAK=0

On further investigation, I found that in the file ~/.local/lib/cmake/libconfig++/libconfig++Config.cmake the prefix variables are not substituted in:

set(LIBCONFIG++_FOUND 1)
set(LIBCONFIG++_VERSION "1.7")
set(LIBCONFIG++_LIBRARIES "config++")
set(LIBCONFIG++_LIBRARY_DIRS "${exec_prefix}/lib")
set(LIBCONFIG++_LDFLAGS "")
set(LIBCONFIG++_INCLUDE_DIRS "${prefix}/include")
set(LIBCONFIG++_CFLAGS "")

Is this supposed to happen during runtime? Printing those out results in /lib and /include. In Fedora, on the other hand, the file itself has both prefixes already replaced with /usr/lib64. But then again, on Archlinux the file looks the same, the prefixes are not substituted in, either, and everything works fine.

autoreconf in libconfig fails with "none" is not exported by the List::Util module.

g++ (GCC) 9.1.0
cmake version 3.15.2

Edit:
I didn't know I had to use the find script from the contrib directory. I assumed finding the library had worked since LIBCONFIG++_FOUND was set to 1. I now use pkg_check_modules to load the PkgConfig into cmake which works on any of my machines.

@zyzzyxdonta zyzzyxdonta changed the title Linking fails when installed locally (cmake) Compiling fails when installed locally (cmake) Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants