Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

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.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant