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

fix: Fixing static compilation issues when installing modules with pip #57

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

Conversation

uniartisan
Copy link

Error message: When trying to link the libre2.a static library, "relocation R_X86_64_TPOFF32 against symbol '_ZN3re25hooks7contextE' can not be used when making a shared object; recompile with -fPIC "problem. This means that the library is not compiled with the -fPIC option, which prevents it from being linked to a shared object.

Error analysis: This error is caused by an attempt to link a static library (in this case libre2.a) that is not compiled with the -fPIC (Position Independent Code) option. Location-independent code means that a program can be executed anywhere in memory, which is important for generating dynamic link libraries. When creating shared or dynamic libraries, you need all object code to be location-independent.

Possible fix description: We can fix this problem by adding the -fPIC option in CMakeLists.txt. We add the -fPIC option when compiling the re2 library, but this changes the upstream content. So I chose to make sure that all targets defined in CMakeLists.txt are set to generate location-independent code by default. This can be done by adding the following line at the top of the CMakeLists.txt file:

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

This way, when you build the libre2.a library again and try to install qwen-cpp, the problem should be resolved.

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.

None yet

1 participant