open-source-parsers / open-source-parsers/jsoncpp

Cannot statically link jsoncpp with my CMake project

Open
#1,537 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug build
Dominant language
C++
Stars
8.9k
Forks
2.7k
Avg merge
31m
Merged PRs (30d)
1

Description

Describe the bug
When I try to statically link jsoncpp into my project, I get the following error message:

[  3%] Linking CXX executable ../../../../bin/jsontestrunner_exe
/usr/bin/ld: cannot find -ljsoncpp_static: No such file or directory

To Reproduce
Steps to reproduce the behavior:

  1. Add the following to CMakeLists.txt file:
set(BUILD_SHARED_LIBS False)
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static")
  1. Run cd build && cmake .. && cmake --build .

Expected behavior
Have a statically linked library

Desktop (please complete the following information):

  • OS: Fedora 40
  • CMake version: 3.28.2
  • Meson version: 1.4.0
  • Ninja version: 1.12.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CMakeLists.txt settings in the reproduction and run the provided cmake and cmake --build commands on the reported setup. Trace why the static build requests jsoncpp_static, then verify that the project produces and links a statically linked library without the reported linker error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.