Skip to content

Position-independent code flag needed in some cases #45

@gussmith23

Description

@gussmith23

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 😄)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions