conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
958 stars 1.76k forks source link

[package] json-schema-validator/2.2.0: JSON_DIAGNOSTICS breaks the library #18340

Open jalapenopuzzle opened 1 year ago

jalapenopuzzle commented 1 year ago

Description

Attempting to use the JSON_DIAGNOSTICS flag with the json-schema-validator library causes link errors and makes the library un-usable.

The remedy is to use a json-schema-validator built with the JSON_DIAGNOSTICS flag enabled. (Pull request to be raised shortly.)

This issue is not particular to the environment shown below. I have reproduced it in other environments as well.

I have attached a small example project to demonstrate the problem. The example project is the json-schema-validator/examples/json-schema-validate.cpp file out of the json-schema-validator repository at https://github.com/pboettch/json-schema-validator .

The JSON_DIAGNOSTICS flag affects the nlohmann_json library, which is in turn required and used by the nlohmann_json_schema_validator library. The JSON_DIAGNOSTICS flag is documented at https://json.nlohmann.me/api/macros/json_diagnostics/. In particular, note that it changes the size of the JSON structure, making it incompatible with any library built without the JSON_DIAGNOSTICS flag (such as nlohmann_json_schema_validator library).

Package and Environment Details

Conan profile

[settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux

Steps to reproduce

conan install . --output-folder=build --build=missing cd build cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release cmake --build .

Logs

Click to expand log ``` ben@red-bearded-flying-dragon:~/conan/testing/test-json-schema-diagnostics$ conan install . --output-folder=build --build=missing ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux Profile build: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux ======== Computing dependency graph ======== json-schema-validator/2.2.0: Not found in local cache, looking in remotes... json-schema-validator/2.2.0: Checking remote: conancenter json-schema-validator/2.2.0: Downloaded recipe revision 19237e39bc303ab6f870c6c24f638ee7 nlohmann_json/3.11.2: Not found in local cache, looking in remotes... nlohmann_json/3.11.2: Checking remote: conancenter nlohmann_json/3.11.2: Downloaded recipe revision a35423bb6e1eb8f931423557e282c7ed Graph root conanfile.py: /home/ben/conan/testing/test-json-schema-diagnostics/conanfile.py Requirements json-schema-validator/2.2.0#19237e39bc303ab6f870c6c24f638ee7 - Downloaded (conancenter) nlohmann_json/3.11.2#a35423bb6e1eb8f931423557e282c7ed - Downloaded (conancenter) ======== Computing necessary packages ======== Requirements json-schema-validator/2.2.0#19237e39bc303ab6f870c6c24f638ee7:2965ddb9dee73c1edaf28905271712353828b54d#c7a1be4fa53ce03f6009b9f32ec45ec9 - Download (conancenter) nlohmann_json/3.11.2#a35423bb6e1eb8f931423557e282c7ed:da39a3ee5e6b4b0d3255bfef95601890afd80709#2d1a5b1f5d673e1dab536bed20ce000b - Download (conancenter) ======== Installing packages ======== -------- Downloading 2 packages -------- nlohmann_json/3.11.2: Retrieving package da39a3ee5e6b4b0d3255bfef95601890afd80709 from remote 'conancenter' nlohmann_json/3.11.2: Package installed da39a3ee5e6b4b0d3255bfef95601890afd80709 nlohmann_json/3.11.2: Downloaded package revision 2d1a5b1f5d673e1dab536bed20ce000b json-schema-validator/2.2.0: Retrieving package 2965ddb9dee73c1edaf28905271712353828b54d from remote 'conancenter' json-schema-validator/2.2.0: Package installed 2965ddb9dee73c1edaf28905271712353828b54d json-schema-validator/2.2.0: Downloaded package revision c7a1be4fa53ce03f6009b9f32ec45ec9 WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'cpp_info.names' used in: json-schema-validator/2.2.0 WARN: deprecated: 'cpp_info.build_modules' used in: json-schema-validator/2.2.0 ======== Finalizing install (deploy, generators) ======== conanfile.py: Writing generators to /home/ben/conan/testing/test-json-schema-diagnostics/build conanfile.py: Generator 'CMakeToolchain' calling 'generate()' conanfile.py: CMakeToolchain generated: conan_toolchain.cmake conanfile.py: Preset 'conan-release' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-release' if using CMake>=3.23 conanfile.py: If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/ben/conan/testing/test-json-schema-diagnostics/build/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release' conanfile.py: CMakeToolchain generated: CMakePresets.json conanfile.py: CMakeToolchain generated: ../CMakeUserPresets.json conanfile.py: Calling generate() conanfile.py: Generators folder: /home/ben/conan/testing/test-json-schema-diagnostics/build conanfile.py: Generating aggregated env files conanfile.py: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] Install finished successfully ben@red-bearded-flying-dragon:~/conan/testing/test-json-schema-diagnostics$ ls build CMakeUserPresets.json json-schema-validate.cpp CMakeLists.txt conanfile.py ben@red-bearded-flying-dragon:~/conan/testing/test-json-schema-diagnostics$ cd build ben@red-bearded-flying-dragon:~/conan/testing/test-json-schema-diagnostics/build$ cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -- Using Conan toolchain: /home/ben/conan/testing/test-json-schema-diagnostics/build/conan_toolchain.cmake -- Conan toolchain: C++ Standard 17 with extensions ON -- The CXX compiler identification is GNU 11.3.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Conan: Target declared 'nlohmann_json::nlohmann_json' -- Conan: Target declared 'nlohmann_json_schema_validator' -- Configuring done -- Generating done -- Build files have been written to: /home/ben/conan/testing/test-json-schema-diagnostics/build ben@red-bearded-flying-dragon:~/conan/testing/test-json-schema-diagnostics/build$ cmake --build . [ 50%] Building CXX object CMakeFiles/json-schema-validate.dir/json-schema-validate.cpp.o [100%] Linking CXX executable json-schema-validate /usr/bin/ld: CMakeFiles/json-schema-validate.dir/json-schema-validate.cpp.o: in function `main': json-schema-validate.cpp:(.text.startup+0x17e): undefined reference to `nlohmann::json_schema::json_validator::json_validator(std::function, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_diag_v3_11_2::adl_serializer, std::vector > >&)>, std::function, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&)>, std::function, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, nlohmann::json_abi_diag_v3_11_2::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_diag_v3_11_2::adl_serializer, std::vector > > const&)>)' /usr/bin/ld: json-schema-validate.cpp:(.text.startup+0x1d7): undefined reference to `nlohmann::json_schema::json_validator::set_root_schema(nlohmann::json_abi_diag_v3_11_2::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_diag_v3_11_2::adl_serializer, std::vector > > const&)' /usr/bin/ld: json-schema-validate.cpp:(.text.startup+0x243): undefined reference to `nlohmann::json_schema::json_validator::validate(nlohmann::json_abi_diag_v3_11_2::basic_json, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_diag_v3_11_2::adl_serializer, std::vector > > const&, nlohmann::json_schema::error_handler&, nlohmann::json_uri const&) const' collect2: error: ld returned 1 exit status gmake[2]: *** [CMakeFiles/json-schema-validate.dir/build.make:98: json-schema-validate] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/json-schema-validate.dir/all] Error 2 gmake: *** [Makefile:91: all] Error 2 ben@red-bearded-flying-dragon:~/conan/testing/test-json-schema-diagnostics/build$ ```
jalapenopuzzle commented 1 year ago

This is the sample project that demonstrates the problem with the json-schema-validator library and the JSON_DIAGNOSTICS flag. test-json-schema-diagnostics.tgz