You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nlohmann_json linked as PRIVATE despite being used in public headers #269
I'm using casbin-cpp as a dependency in another CMake project alongside another library that also depends on a different version of nlohmann_json. This results in undefined symbol errors caused by an ABI mismatch. The issue is that casbin/CMakeLists.txt links with nlohmann_json as PRIVATE, however nlohmann_json is part of casbin's public API. These three headers include <nlohmann/json.hpp and expose nlohmann::json types directly:
include/casbin/casbin_types.h
include/casbin/model/evaluator.h
include/casbin/data_types.h
Since the linkage is PRIVATE, CMake doesn't propagate casbin's nlohmann_json target downstream to consumers and when another dependency brings in a different version, the compiler resolves casbin's headers against the wrong version, leading to ABI mismatches at link time.
The fix would be to change PRIVATE to PUBLIC:
-target_link_libraries(casbin PRIVATE nlohmann_json::nlohmann_json)+target_link_libraries(casbin PUBLIC nlohmann_json::nlohmann_json)
Activity
hsluoyz commentedon Feb 7, 2026
@aaronaranda sounds good, PR is welcome