Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexrp
Copy link

@alexrp alexrp commented Apr 11, 2024

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

Comment on lines +4 to +6
if (BUILD_SHARED_LIBS)
set_property(TARGET "minilzo" PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contradicts the previous line where "minilzo" is only compiled as a STATIC library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it? The idea is to build minilzo as a static library, but still as PIC, because that static library gets incorporated into the matroska2 shared library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants