pboettch / json-schema-validator

JSON schema validator for JSON for Modern C++
Other
463 stars 133 forks source link

Linkage error: incomplete definition of type #318

Closed Cianidos closed 2 months ago

Cianidos commented 2 months ago

Hi Have next problem while compilation

[root@ce96d52667a0 cpp-tmpl-ctl]# ./build.py build
['src/api.cpp', 'src/json_definitions.cpp', 'src/main.cpp']
In file included from src/main.cpp:15:
In file included from /usr/local/include/nlohmann/json-schema.hpp:24:
In file included from /usr/local/include/nlohmann/json.hpp:41:
In file included from /usr/local/include/nlohmann/detail/input/binary_reader.hpp:25:
/usr/local/include/nlohmann/detail/input/input_adapters.hpp:330:9: error: implicit instantiation of undefined template 'nlohmann::detail::wide_string_input_helper<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, 40>'
  330 |         wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
      |         ^
/usr/local/include/nlohmann/detail/input/input_adapters.hpp:312:13: note: in instantiation of function template specialization 'nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>::fill_buffer<40UL>' requested here
  312 |             fill_buffer<sizeof(WideCharType)>();
      |             ^
/usr/local/include/nlohmann/detail/input/lexer.hpp:1349:26: note: in instantiation of member function 'nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>::get_character' requested here
 1349 |             current = ia.get_character();
      |                          ^
/usr/local/include/nlohmann/detail/input/lexer.hpp:1488:13: note: in instantiation of member function 'nlohmann::detail::lexer<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::get' requested here
 1488 |         if (get() == 0xEF)
      |             ^
/usr/local/include/nlohmann/detail/input/lexer.hpp:1512:48: note: in instantiation of member function 'nlohmann::detail::lexer<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::skip_bom' requested here
 1512 |         if (position.chars_read_total == 0 && !skip_bom())
      |                                                ^
/usr/local/include/nlohmann/detail/input/parser.hpp:463:37: note: in instantiation of member function 'nlohmann::detail::lexer<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::scan' requested here
  463 |         return last_token = m_lexer.scan();
      |                                     ^
/usr/local/include/nlohmann/detail/input/parser.hpp:80:9: note: in instantiation of member function 'nlohmann::detail::parser<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::get_token' requested here
   80 |         get_token();
      |         ^
/usr/local/include/nlohmann/json.hpp:135:16: note: in instantiation of member function 'nlohmann::detail::parser<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::parser' requested here
  135 |         return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
      |                ^
/usr/local/include/nlohmann/json.hpp:4014:9: note: in instantiation of function template specialization 'nlohmann::basic_json<>::parser<nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>' requested here
 4014 |         parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
      |         ^
src/main.cpp:91:35: note: in instantiation of function template specialization 'nlohmann::basic_json<>::parse<std::filesystem::path &>' requested here
   91 |   validator.set_root_schema(json::parse(template_path));
      |                                   ^
/usr/local/include/nlohmann/detail/input/input_adapters.hpp:175:8: note: template is declared here
  175 | struct wide_string_input_helper;
      |        ^
/usr/local/include/nlohmann/detail/input/input_adapters.hpp:330:54: error: incomplete definition of type 'nlohmann::detail::wide_string_input_helper<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, 40>'
  330 |         wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
2 errors generated.

I tried various environments... host os is macOS, but everything done in docker containers debian arm64 + getting nlohmann-json and json-schema-validator by vcpkg fedora:39 x64 + getting nlohmann-json and json-schema-validator by vcpkg fedora:39 x64 + compiling json-schema-validator and getting nlohmann-json from source Also I tried various compilation flags and etc...

Error message above got by last env

I build my project by simple clang++ call via python script

#!/usr/bin/python

import os
import subprocess
import sys

args = sys.argv
script_name = args[0]

# Define directories and output file
build_folder = "./build"
output_file = "debug"
src_dir = "src"

def build():

    # Find all source files
    files = []
    for root, _, filenames in os.walk(src_dir):
        for filename in filenames:
            if filename.endswith(('.cpp')):
                files.append(os.path.join(root, filename))

    print(files)

    # Create build directory if not exists
    os.makedirs(build_folder, exist_ok=True)

    # Build command
    cmd = [
        "clang++",
        "-std=c++20",
        "-Wall", "-Wextra", "-pedantic-errors",
        "-D_GLIBCXX_DEBUG", "--debug", "-Og", "-ggdb3",
        "-I/workspace/cpp-templ-ctl/lib/json/include",
        "-I/usr/local/include",
        "-L/usr/local/lib64",
        "-I/root/vcpkg/installed/x64-linux/include",
        "-L/root/vcpkg/installed/x64-linux/lib"
    ]
    cmd.extend(files)
    cmd.extend([
        "-o", f"{build_folder}/{output_file}",
        "-lnlohmann_json_schema_validator",
        "-lreproc++",
        "-lreproc",
        "-lcryptopp"
    ])

    # Execute build command
    subprocess.run(cmd)

def run():
    build_folder = "./build"
    output_file = "debug"
    executable = f"{build_folder}/{output_file}"
    subprocess.run([executable])

def clear():
    build_folder = "./build"
    # Remove build directory and its contents
    subprocess.run(["rm", "-rf", build_folder])

def main():
    command = None

    if len(args) > 1:
        command = args[1]
    else:
        command = input("Enter command (build, run, clear): ").strip()

    if command == "build":
        build()
    elif command == "run":
        run()
    elif command == "clear":
        clear()
    else:
        print("Unknown command")

if __name__ == "__main__":
    main()

But I'm pretty sure that neither the operating system, nor the build method, nor my code, are involved in the problem.

library versions is: json - 3.11.13, json-schema-validator - 2.3.0

Thank you in advance

LecrisUT commented 2 months ago

I would not recommend that you compile by hand like that unless you know how build systems work and how to debug them. Please use the cmake build, or explain in more detail what you want to achieve

pboettch commented 2 months ago

What does "-pedantic-errors", do, if you only compile a test-program with nlohmann-json includes?

LecrisUT commented 2 months ago

The error indicates it's an error with templates and not a warning that updraded to error. But that build is hard to reproduce because of the manual link flags and unknown installation environment

Cianidos commented 2 months ago

I would not recommend that you compile by hand like that unless you know how build systems work and how to debug them. Please use the cmake build, or explain in more detail what you want to achieve

I tried with cmake, same errors happened.

What does "-pedantic-errors", do, if you only compile a test-program with nlohmann-json includes? only nlohman-json works fine. I have errors only if add json-schema-validator.

The error indicates it's an error with templates and not a warning that updraded to error. But that build is hard to reproduce because of the manual link flags and unknown installation environment

I tried without extra flags, so I can write docker file, to reproduce error in stable env. please wait.

(now I just took valijson lib instead of this...)

Cianidos commented 2 months ago

So, I found the reason... It was -D_GLIBCXX_DEBUG compilation flag And docker to reproduce ./Dockerfile

FROM --platform=amd64 fedora:39

RUN dnf update -y
RUN dnf install -y make automake gcc gcc-c++ git g++ clang ninja-build cmake curl zip unzip tar

WORKDIR /root
RUN git clone https://github.com/Microsoft/vcpkg.git 
WORKDIR /root/vcpkg
RUN ./bootstrap-vcpkg.sh
RUN ./vcpkg install nlohmann-json json-schema-validator

COPY ./main.cpp ./main.cpp

RUN clang++ -std=c++20 -D_GLIBCXX_DEBUG -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator

./main.cpp

#include "nlohmann/json-schema.hpp"
#include "nlohmann/json.hpp"

using json = nlohmann::json;

int main(int argc, char* argv[]) {
  json some = json("{}");
  nlohmann::json_schema::json_validator validator;
  validator.set_root_schema(some);
  validator.validate(some);
  return 0;
}
[$] docker buildx build -t test.cpp.json.error .                                                                                                                                                                               [22:47:28]
[+] Building 5.8s (14/14) FINISHED                                                                                                                                                                                     docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                                   0.1s
 => => transferring dockerfile: 554B                                                                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/fedora:39                                                                                                                                                                           0.5s
 => [ 1/10] FROM docker.io/library/fedora:39@sha256:06df381d697d14940c886fda8e94a4fdc838df74e93f65111ed3ea04f7a7d6e0                                                                                                                   0.0s
 => [internal] load build context                                                                                                                                                                                                      0.0s
 => => transferring context: 30B                                                                                                                                                                                                       0.0s
 => CACHED [ 2/10] RUN dnf update -y                                                                                                                                                                                                   0.0s
 => CACHED [ 3/10] RUN dnf install -y make automake gcc gcc-c++ git g++ clang ninja-build cmake curl zip unzip tar                                                                                                                     0.0s
 => CACHED [ 4/10] WORKDIR /root                                                                                                                                                                                                       0.0s
 => CACHED [ 5/10] RUN git clone https://github.com/Microsoft/vcpkg.git                                                                                                                                                                0.0s
 => CACHED [ 6/10] WORKDIR /root/vcpkg                                                                                                                                                                                                 0.0s
 => CACHED [ 7/10] RUN ./bootstrap-vcpkg.sh                                                                                                                                                                                            0.0s
 => CACHED [ 8/10] RUN ./vcpkg install nlohmann-json json-schema-validator                                                                                                                                                             0.0s
 => CACHED [ 9/10] COPY ./main.cpp ./main.cpp                                                                                                                                                                                          0.0s
 => ERROR [10/10] RUN clang++ -std=c++20 -D_GLIBCXX_DEBUG -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator                                            5.2s
------                                                                                                                                                                                                                                      
 > [10/10] RUN clang++ -std=c++20 -D_GLIBCXX_DEBUG -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator:
5.107 /usr/bin/ld: /tmp/main-aee481.o: in function `main':
5.109 main.cpp:(.text+0x8d): undefined reference to `nlohmann::json_schema::json_validator::json_validator(std::function<void (nlohmann::json_uri const&, nlohmann::json_abi_v3_11_3::basic_json<std::__debug::map, std::__debug::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::__debug::vector<unsigned char, std::allocator<unsigned char> >, void>&)>, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, nlohmann::json_abi_v3_11_3::basic_json<std::__debug::map, std::__debug::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::__debug::vector<unsigned char, std::allocator<unsigned char> >, void> const&)>)'
5.111 /usr/bin/ld: main.cpp:(.text+0xbd): undefined reference to `nlohmann::json_schema::json_validator::set_root_schema(nlohmann::json_abi_v3_11_3::basic_json<std::__debug::map, std::__debug::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::__debug::vector<unsigned char, std::allocator<unsigned char> >, void> const&)'
5.111 /usr/bin/ld: main.cpp:(.text+0xd6): undefined reference to `nlohmann::json_schema::json_validator::validate(nlohmann::json_abi_v3_11_3::basic_json<std::__debug::map, std::__debug::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::__debug::vector<unsigned char, std::allocator<unsigned char> >, void> const&) const'
5.125 clang++: error: linker command failed with exit code 1 (use -v to see invocation)
------
Dockerfile:14
--------------------
  12 |     COPY ./main.cpp ./main.cpp
  13 |     
  14 | >>> RUN clang++ -std=c++20 -D_GLIBCXX_DEBUG -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator
--------------------
ERROR: failed to solve: process "/bin/sh -c clang++ -std=c++20 -D_GLIBCXX_DEBUG -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator" did not complete successfully: exit code: 1
pboettch commented 2 months ago
5.111 /usr/bin/ld: main.cpp:(.text+0xbd): undefined reference to `nlohmann::json_schema::json_validator::set_root_schema(nlohmann::json_abi_v3_11_3::basic_json<std::__debug::map, std::__debug::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::__debug::vector<unsigned char, std::allocator<unsigned char> >, void> const&)'
5.111 /usr/bin/ld: main.cpp:(.text+0xd6): undefined reference to `nlohmann::json_schema::json_validator::validate(nlohmann::json_abi_v3_11_3::basic_json<std::__debug::map, std::__debug::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_3::adl_serializer, std::__debug::vector<unsigned char, std::allocator<unsigned char> >, void> const&) const'

How is this the same error (here a linker error) than the one you had above, which was a compile error?

Cianidos commented 2 months ago

I apologize, that's the wrong error. I double-checked with my project, and it's the same.... I jumped to conclusions I will try again to reproduce the error that I had at the beginning, but outside my project

Cianidos commented 2 months ago

I got it. ./Dockerfile

FROM --platform=amd64 fedora:39

RUN dnf update -y
RUN dnf install -y make automake gcc gcc-c++ git g++ clang ninja-build cmake curl zip unzip tar

WORKDIR /root
RUN git clone https://github.com/Microsoft/vcpkg.git 
WORKDIR /root/vcpkg
RUN ./bootstrap-vcpkg.sh
RUN ./vcpkg install nlohmann-json json-schema-validator

COPY ./main.cpp ./main.cpp

RUN clang++ -std=c++20  -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator

./main.cpp

#include <filesystem>
#include <string>

#include "nlohmann/json-schema.hpp"
#include "nlohmann/json.hpp"

using json = nlohmann::json;

int main(int argc, char* argv[]) {
  json some{""};
  nlohmann::json_schema::json_validator validator;
  //                                      just took any file to be in path
  validator.set_root_schema(json::parse(std::filesystem::path("./main.cpp")));
  validator.validate(some);
  return 0;
}
[$] docker buildx build -t test.cpp.json.error .                                                                                                                                                                               [23:23:16]
[+] Building 3.5s (14/14) FINISHED                                                                                                                                                                                     docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 538B                                                                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/fedora:39                                                                                                                                                                           0.6s
 => [ 1/10] FROM docker.io/library/fedora:39@sha256:06df381d697d14940c886fda8e94a4fdc838df74e93f65111ed3ea04f7a7d6e0                                                                                                                   0.0s
 => [internal] load build context                                                                                                                                                                                                      0.0s
 => => transferring context: 30B                                                                                                                                                                                                       0.0s
 => CACHED [ 2/10] RUN dnf update -y                                                                                                                                                                                                   0.0s
 => CACHED [ 3/10] RUN dnf install -y make automake gcc gcc-c++ git g++ clang ninja-build cmake curl zip unzip tar                                                                                                                     0.0s
 => CACHED [ 4/10] WORKDIR /root                                                                                                                                                                                                       0.0s
 => CACHED [ 5/10] RUN git clone https://github.com/Microsoft/vcpkg.git                                                                                                                                                                0.0s
 => CACHED [ 6/10] WORKDIR /root/vcpkg                                                                                                                                                                                                 0.0s
 => CACHED [ 7/10] RUN ./bootstrap-vcpkg.sh                                                                                                                                                                                            0.0s
 => CACHED [ 8/10] RUN ./vcpkg install nlohmann-json json-schema-validator                                                                                                                                                             0.0s
 => CACHED [ 9/10] COPY ./main.cpp ./main.cpp                                                                                                                                                                                          0.0s
 => ERROR [10/10] RUN clang++ -std=c++20  -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator                                                            2.9s
------                                                                                                                                                                                                                                      
 > [10/10] RUN clang++ -std=c++20  -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator:
2.863 In file included from main.cpp:4:
2.863 In file included from /root/vcpkg/installed/x64-linux/include/nlohmann/json-schema.hpp:24:
2.863 In file included from /root/vcpkg/installed/x64-linux/include/nlohmann/json.hpp:40:
2.863 In file included from /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/binary_reader.hpp:25:
2.863 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/input_adapters.hpp:329:9: error: implicit instantiation of undefined template 'nlohmann::detail::wide_string_input_helper<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, 40>'
2.866   329 |         wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
2.866       |         ^
2.868 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/input_adapters.hpp:311:13: note: in instantiation of function template specialization 'nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>::fill_buffer<40UL>' requested here
2.871   311 |             fill_buffer<sizeof(WideCharType)>();
2.873       |             ^
2.874 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/lexer.hpp:1350:26: note: in instantiation of member function 'nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>::get_character' requested here
2.875  1350 |             current = ia.get_character();
2.875       |                          ^
2.875 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/lexer.hpp:1489:13: note: in instantiation of member function 'nlohmann::detail::lexer<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::get' requested here
2.875  1489 |         if (get() == 0xEF)
2.875       |             ^
2.875 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/lexer.hpp:1513:48: note: in instantiation of member function 'nlohmann::detail::lexer<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::skip_bom' requested here
2.875  1513 |         if (position.chars_read_total == 0 && !skip_bom())
2.876       |                                                ^
2.876 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/parser.hpp:475:37: note: in instantiation of member function 'nlohmann::detail::lexer<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::scan' requested here
2.876   475 |         return last_token = m_lexer.scan();
2.876       |                                     ^
2.876 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/parser.hpp:80:9: note: in instantiation of member function 'nlohmann::detail::parser<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::get_token' requested here
2.876    80 |         get_token();
2.876       |         ^
2.876 /root/vcpkg/installed/x64-linux/include/nlohmann/json.hpp:139:16: note: in instantiation of member function 'nlohmann::detail::parser<nlohmann::basic_json<>, nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>::parser' requested here
2.876   139 |         return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
2.876       |                ^
2.876 /root/vcpkg/installed/x64-linux/include/nlohmann/json.hpp:4021:9: note: in instantiation of function template specialization 'nlohmann::basic_json<>::parser<nlohmann::detail::wide_string_input_adapter<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, std::filesystem::path>>' requested here
2.876  4021 |         parser(detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(true, result);
2.876       |         ^
2.876 main.cpp:12:35: note: in instantiation of function template specialization 'nlohmann::basic_json<>::parse<std::filesystem::path>' requested here
2.876    12 |   validator.set_root_schema(json::parse(std::filesystem::path("./main.cpp")));
2.876       |                                   ^
2.877 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/input_adapters.hpp:174:8: note: template is declared here
2.877   174 | struct wide_string_input_helper;
2.877       |        ^
2.877 /root/vcpkg/installed/x64-linux/include/nlohmann/detail/input/input_adapters.hpp:329:54: error: incomplete definition of type 'nlohmann::detail::wide_string_input_helper<nlohmann::detail::iterator_input_adapter<std::filesystem::path::iterator>, 40>'
2.878   329 |         wide_string_input_helper<BaseInputAdapter, T>::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled);
2.878       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
2.895 2 errors generated.
------
Dockerfile:14
--------------------
  12 |     COPY ./main.cpp ./main.cpp
  13 |     
  14 | >>> RUN clang++ -std=c++20  -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator
--------------------
ERROR: failed to solve: process "/bin/sh -c clang++ -std=c++20  -I/root/vcpkg/installed/x64-linux/include -L/root/vcpkg/installed/x64-linux/lib main.cpp -o main -lnlohmann_json_schema_validator" did not complete successfully: exit code: 1
Cianidos commented 2 months ago

Oh, my God. it works like this validator.set_root_schema(json::parse(std::string(std::filesystem::path("./main.cpp")))); this mind-bogglingly stupid error ate up ~20 hours of time, because it looked like a library problem, not a problem of my crooked hands.

sorry, for time

pboettch commented 2 months ago

As a compensation for us, you have to try to use this library and possibly get rid of valijson ;-). (I don't know valijson so I don't know if it is actually better than this library.)