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

tests fail: cannot find -lnlohmann_json #101

Closed
yurivict opened this issue Aug 10, 2018 · 10 comments · Fixed by #102
Closed

tests fail: cannot find -lnlohmann_json #101

yurivict opened this issue Aug 10, 2018 · 10 comments · Fixed by #102

Comments

@yurivict
Copy link

/usr/bin/c++  -O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion -march=native -std=c++14 -O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer  -fstack-protector CMakeFiles/test_xtl.dir/main.cpp.o CMakeFiles/test_xtl.dir/test_xbase64.cpp.o CMakeFiles/test_xtl.dir/test_xbasic_fixed_string.cpp.o CMakeFiles/test_xtl.dir/test_xcomplex.cpp.o CMakeFiles/test_xtl.dir/test_xcomplex_sequence.cpp.o CMakeFiles/test_xtl.dir/test_xclosure.cpp.o CMakeFiles/test_xtl.dir/test_xdynamic_bitset.cpp.o CMakeFiles/test_xtl.dir/test_xhash.cpp.o CMakeFiles/test_xtl.dir/test_xhierarchy_generator.cpp.o CMakeFiles/test_xtl.dir/test_xiterator_base.cpp.o CMakeFiles/test_xtl.dir/test_xmeta_utils.cpp.o CMakeFiles/test_xtl.dir/test_xoptional.cpp.o CMakeFiles/test_xtl.dir/test_xtype_traits.cpp.o CMakeFiles/test_xtl.dir/test_xproxy_wrapper.cpp.o CMakeFiles/test_xtl.dir/test_xvariant.cpp.o  -o test_xtl  -Wl,-rpath,/usr/local/lib -lnlohmann_json /usr/local/lib/libgtest.so /usr/local/lib/libgtest_main.so -pthread && :
/usr/bin/ld: cannot find -lnlohmann_json

nlohmann-json is a headers-only library:

$ pkg info -l nlohmann-json-3.1.2
nlohmann-json-3.1.2:
        /usr/local/include/nlohmann/json.hpp
        /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonConfig.cmake
        /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonConfigVersion.cmake
        /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonTargets.cmake
        /usr/local/share/licenses/nlohmann-json-3.1.2/LICENSE
        /usr/local/share/licenses/nlohmann-json-3.1.2/MIT
        /usr/local/share/licenses/nlohmann-json-3.1.2/catalog.mk

and there should never be -lnlohmann_json for it.

@SylvainCorlay
Copy link
Member

nlohmann_json is an optional dependency but is still required for the test target.

This was reported earlier this week. We should either specify that it is required for the test target or skipp the corresponding tests when missing.

@yurivict
Copy link
Author

... or skipp the corresponding tests when missing.

It is always missing as a .so library, because it is a headers-only library.

@SylvainCorlay
Copy link
Member

I don't think so. This is just that when it does not find a target, cmake assumes that you are trying to link with a library.

@yurivict
Copy link
Author

Why can't it find the target? nlohmann-json-3.1.2 is installed.

@BeneSim
Copy link
Contributor

BeneSim commented Aug 12, 2018

@yurivict Any chance you installed nlohmann-json from the master branch? The nlohmann-json project adapted it's targets to the more modern namespaced style with this PR nlohmann/json#1048 . However there has been no release since then. The travis etc. tests work because they use the target nlohmann-json (from version 3.1.2) if you pull from the master branch you need to link against the new target nlohmann_json::nlohmann_json. I've got an upcomming PR that fixes those issues.

@yurivict
Copy link
Author

nlohmann-json is of version 3.1.2.

@BeneSim
Copy link
Contributor

BeneSim commented Aug 12, 2018

Are you building from the xtl root project? Or are you building in the test subdirectory? There is another bug in the related CMakeLists.txt where it won't try to find the nlohmann_json package, will also be fixed with the PR.

@yurivict
Copy link
Author

Building in the test subdirectory.

@BeneSim
Copy link
Contributor

BeneSim commented Aug 12, 2018

That'll be the issue, you could try changing

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
    project(xtl-test)

    find_package(xtl REQUIRED CONFIG)
    set(XTL_INCLUDE_DIR ${xtl_INCLUDE_DIRS})
endif ()

in CMakeLists.txt to

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
    project(xtl-test)

    find_package(xtl REQUIRED CONFIG)
    find_package(nlohmann_json QUIET)
    set(XTL_INCLUDE_DIR ${xtl_INCLUDE_DIRS})
endif ()

@yurivict
Copy link
Author

That'll be the issue, you could try changing ...

This helped, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants