Skip to content

Instantly share code, notes, and snippets.

@lucbettaieb
Last active April 12, 2021 23:22
Show Gist options
  • Save lucbettaieb/0d66ae2d490438389581bb3ee7a92e80 to your computer and use it in GitHub Desktop.
Save lucbettaieb/0d66ae2d490438389581bb3ee7a92e80 to your computer and use it in GitHub Desktop.

Linking against jsoncpp using CMake

This one sucked

  1. Build jsoncpp
git clone https://github.com/open-source-parsers/jsoncpp.git; (cd jsoncpp && mkdir build)
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=ON -G "Unix Makefiles" ../; make; make install
  1. Know: The static lib is called jsoncpp_static and the shared is jsoncpp_lib. smh.
  2. In your CMakeLists.txt do a
find_package(jsoncpp REQUIRED)
  1. And then do a
target_link_libraries(your_lib
  jsoncpp_lib
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment