dectris / documentation

A repository of documentation for DECTRIS products
5 stars 4 forks source link

Enable building stream2 into a shared lib #3

Closed GDYendell closed 1 year ago

GDYendell commented 1 year ago

Currently attempting to build a shared library against stream2 gives errors like:

relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC

Adding the compiler flag to the stream2, cbor and compression CMakeLists makes it work (e.g.), but I am not sure what the side effects of this would be.

It would be great to be able to build a shared library against main, however that may be implemented.

kalcutter commented 1 year ago

@GDYendell It looks like the CMake-idiomatic solution is to simply do the following:

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Setting this variable will recursively affect subsequent directories/dependent projects. Can you try setting this variable in your project?

GDYendell commented 1 year ago

Yep that works. Thanks, @kalcutter! e.g.