how to reproduce:
#include <format/format.h>
int main() {
fmt::print("hello world");
}
$ g++ -I ./support/deps/include/ -pie test.cpp ./support/deps/lib/libcppformat.a
/usr/bin/ld: /tmp/ccPx6StM.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/tmp/ccPx6StM.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Following the compiler's advice results in a working library but I don't know how to patch the cmake recipe
To enable compilation with -fPIC use the following CMake command:
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ...
Thanks for the correction!
Most helpful comment
To enable compilation with
-fPICuse the following CMake command: