Matroska-Org / foundation-source

libEBML2, libMatroska2, mkvalidator, mkclean and the specifications
55 stars 29 forks source link

Build helper libraries with position-independent code if BUILD_SHARED_LIBS is set. #144

Open alexrp opened 4 months ago

alexrp commented 4 months ago

If this is not done, cmake .. -DBUILD_SHARED_LIBS=ON && cmake --build . will fail like so:

/usr/bin/ld: ../corec/corec/helpers/zlib/libzlib.a(deflate.c.o): warning: relocation against `z_errmsg' in read-only section `.text'
/usr/bin/ld: ../corec/corec/helpers/zlib/libzlib.a(zutil.c.o): relocation R_X86_64_PC32 against symbol `z_errmsg' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
gmake[2]: *** [libmatroska2/CMakeFiles/matroska2.dir/build.make:132: libmatroska2/libmatroska2.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:492: libmatroska2/CMakeFiles/matroska2.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

(And so on for each static helper library.)