If the library cannot be found, please update vcpkg itself to make sure the newest ports are installed. You
might also want to update the builtin-baseline tag in the vcpkg.json of your project.
If you want to support formats other than JSON, please install the appropriate vcpkg features. Refer to the
link above to find out which features are supported in the vcpkg port.
Option 4: Include source files into your own build¶
Simply copy the contents of the folders include and src into your source repository or add it to your include path and also add src/reflectcpp.cpp and src/reflectcpp_json.cpp and src/yyjson.c to your source files for compilation.
If you want to link to your own version of YYJSON, then only add src/reflectcpp.cpp and src/reflectcpp_json.cpp. If you don't need JSON support, then only add src/reflectcpp.cpp.
If you need support for other serialization formats like flexbuffers or XML, you should also add src/reflectcpp_<format>.cpp and include and link the respective libraries, as listed in the section on serialization formats.
If you want serialization formats other than JSON, you can either install them manually or use vcpkg.
To install vcpkg:
gitsubmoduleupdate--init
./vcpkg/bootstrap-vcpkg.sh# Linux, macOS
./vcpkg/bootstrap-vcpkg.bat# Windows# You may be prompted to install additional dependencies.
add_subdirectory(reflect-cpp)# Add this project as a subdirectoryset(REFLECTCPP_AVROON)# Optionalset(REFLECTCPP_BSONON)# Optionalset(REFLECTCPP_CBORON)# Optionalset(REFLECTCPP_FLEXBUFFERSON)# Optionalset(REFLECTCPP_MSGPACKON)# Optionalset(REFLECTCPP_TOMLON)# Optionalset(REFLECTCPP_UBJSONON)# Optionalset(REFLECTCPP_XMLON)# Optionalset(REFLECTCPP_YAMLON)# Optionaltarget_link_libraries(your_projectPRIVATEreflectcpp)# Link against the library
vcpkg is a great, but very ambitious and complex project (just like C++ is a great, but very ambitious and complex language). Here are some of the you might run into and how to resolve them:
A lot of problems can simply be resolved by deleting the build directory using rm -rf build.
Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm, s390x, ppc64le and riscv platforms. - This usually happens on arm platforms like the Apple Silicon chips and can be resolved by simply preceding your build with export VCPKG_FORCE_SYSTEM_BINARIES=arm or export VCPKG_FORCE_SYSTEM_BINARIES=1.
On some occasions you might be asked to specify a compiler. You can do so by simply adding it to the cmake command as follows: cmake -S . -B build ... -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ or cmake -S . -B build ... -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17 (or whatever supported compiler you would like to use).