Skip to content

tests fail: cannot find -lnlohmann_json #101

Description

@yurivict
/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.

Activity

  1. SylvainCorlay commented on Aug 10, 2018

    @SylvainCorlay
    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.

  2. yurivict commented on Aug 10, 2018

    @yurivict
    Author

    ... or skipp the corresponding tests when missing.

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

  3. SylvainCorlay commented on Aug 10, 2018

    @SylvainCorlay
    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.

  4. yurivict commented on Aug 10, 2018

    @yurivict
    Author

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

  5. BeneSim commented on Aug 12, 2018

    @BeneSim
    Contributor

    @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.

  6. yurivict commented on Aug 12, 2018

    @yurivict
    Author

    nlohmann-json is of version 3.1.2.

  7. BeneSim commented on Aug 12, 2018

    @BeneSim
    Contributor

    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.

  8. yurivict commented on Aug 12, 2018

    @yurivict
    Author

    Building in the test subdirectory.

  9. BeneSim commented on Aug 12, 2018

    @BeneSim
    Contributor

    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 ()
  10. yurivict commented on Aug 12, 2018

    @yurivict
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions