anhero / JsonBox

This is a JSON C++ library. It can write and read JSON files with ease and speed.
MIT License
115 stars 60 forks source link

Position-independent code flag needed in some cases #45

Open gussmith23 opened 6 years ago

gussmith23 commented 6 years ago

When linking against a debug, static version of JsonBox, I needed to add the setting set(CMAKE_POSITION_INDEPENDENT_CODE ON) in JsonBox's CMakeLists.txt before making and installing it to my system. Otherwise, I get the linker error described in this SO question.

I'm not necessarily asking that this setting be added into JsonBox in all cases, nor am I asking that it even be added in any case; I am just bringing to light a problem I faced and making sure others are aware of it. (This is the first time I've hit this issue, but if it's a common problem, feel free to chalk it up to my ignorance :smile:)

Note that for any users running into this issue, another solution (I suspect) is to add JsonBox as a target within your CMake-managed project, instead of depending on an installed version on your system. You can then add the CMAKE_POSITION_INDEPENDENT_CODE ON setting to the JsonBox target.