xeco23/WasIstLos

build fails with ld: error: can't create dynamic relocation R_X86_64_64

Opened this issue · 0 comments

Description
When building from source, at the linking stage, the following error is produced:

ld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output

To Reproduce
Steps to reproduce the behavior:
Install all dev dependencies and build according to the README instructions.

Expected behavior
Build should work.

Environment

  • Distro Mint 20.3
  • Package git clone

Adding the following line to CMakeLists.txt fixes the issue:

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

(from https://stackoverflow.com/questions/38296756/what-is-the-idiomatic-way-in-cmake-to-add-the-fpic-compiler-option)