C++ 将静态(.a)库与共享(.so)库链接,出现错误";根据本地符号重新定位R_X86_64_32S;使用-fPIC“重新编译”;

C++ 将静态(.a)库与共享(.so)库链接,出现错误";根据本地符号重新定位R_X86_64_32S;使用-fPIC“重新编译”;,c++,eclipse,64-bit,fpic,C++,Eclipse,64 Bit,Fpic,使用eclipse在redhat中使用g++64位进行编译 编译错误: ../lib-EL5-64位/libskd3_clnt_30134500.a(skd_clnt.o):在创建共享对象时,不能使用针对“本地符号”的重新定位R_X86_64_32S;用-fPIC重新编译 我尝试过的事情 我将FPIC添加到C++编译器标志以及链接标志中。它已经存在于编译器标志中,我只是将它直接移到g++之后,并在列表的末尾 我已经要求.a库的创建者使用-fPIC重新编译,但它仍然给出相同的错误 有没有办法确保他

使用eclipse在redhat中使用g++64位进行编译

编译错误: ../lib-EL5-64位/libskd3_clnt_30134500.a(skd_clnt.o):在创建共享对象时,不能使用针对“本地符号”的重新定位R_X86_64_32S;用-fPIC重新编译

我尝试过的事情 我将FPIC添加到C++编译器标志以及链接标志中。它已经存在于编译器标志中,我只是将它直接移到g++之后,并在列表的末尾

我已经要求.a库的创建者使用-fPIC重新编译,但它仍然给出相同的错误

有没有办法确保他们的库是用-fPIC编译的? 错误消息是说我需要用-fPIC编译我的.so,还是说.a文件需要用-fPIC编译? 我还能查什么

这是make文件(由eclipse自动生成)

生成文件:

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include generic_d2s/subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables 

# All Target
all: libFUSE.so

# Tool invocations
libFUSE.so: $(OBJS) $(USER_OBJS)
    @echo 'Building target: $@'
    @echo 'Invoking: GCC C++ Linker'
    g++ -fPIC -L../../CRYPTOPP/lib-EL5-64bit -L../lib-EL5-64bit -Wl,-rpath /lib -shared -o"libFUSE.so" $(OBJS) $(USER_OBJS) $(LIBS)
    @echo 'Finished building target: $@'
    @echo ' '

# Other Targets
clean:
    -$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(LIBRARIES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libFUSE.so
    -@echo ' '

.PHONY: all clean dependents
.SECONDARY:

-include ../makefile.targets
subdir.mk

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

# Add inputs and outputs from these tool invocations to the build variables 
CPP_SRCS += \
../CRI.cpp 


C_SRCS += \
../client_rsa.c 

OBJS += \
./CRI.o 


C_DEPS += \
./client_rsa.d 

CPP_DEPS += \
./CRI.d 


# Each subdirectory must supply rules for building sources it contributes
%.o: ../%.cpp
    @echo 'Building file: $<'
    @echo 'Invoking: GCC C++ Compiler'
    g++ -D_TM_CDIR='"/proj/kronos/test/hho/testprograms/trunk/testmethods/FUSE"' -I../../CRYPTOPP/include/cryptopp -I"/opt/hp93000/soc/pws/lib" -I"/opt/hp93000/soc/com/include" -I/opt/hp93000/soc/prod_com/include -I/opt/hp93000/soc/prod_com/include/MAPI -I/opt/hp93000/soc/testmethod/include -O0 -g3 -Wall -c -fmessage-length=0 -shared -fPIC  -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wunknown-pragmas -Wsign-compare -Wconversion -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
    @echo 'Finished building: $<'
    @echo ' '

%.o: ../%.c
    @echo 'Building file: $<'
    @echo 'Invoking: GCC C Compiler'
    gcc -D_TM_CDIR='"/proj/kronos/test/hho/testprograms/trunk/testmethods/FUSE"' -I/opt/hp93000/soc/prod_com/include -I/opt/hp93000/soc/prod_com/include/MAPI -I/opt/hp93000/soc/testmethod/include -I/opt/hp93000/soc/com/include -I/opt/hp93000/soc/pws/lib -O0 -g3 -Wall -c -fmessage-length=0 -fPIC  -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wunknown-pragmas -Wsign-compare -Wconversion -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
    @echo 'Finished building: $<'
    @echo ' '
sources.mk

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

O_SRCS := 
CPP_SRCS := 
C_UPPER_SRCS := 
C_SRCS := 
S_UPPER_SRCS := 
OBJ_SRCS := 
ASM_SRCS := 
CXX_SRCS := 
C++_SRCS := 
CC_SRCS := 
OBJS := 
C++_DEPS := 
C_DEPS := 
CC_DEPS := 
LIBRARIES := 
CPP_DEPS := 
CXX_DEPS := 
C_UPPER_DEPS := 

# Every subdirectory with source files must be described here
SUBDIRS := \
. \
generic_d2s \

当静态编译时,汇编指令将假定代码的某些位置,例如,任何跳转都在跳转/调用指令的4GB范围内。(假设64b x86)。共享库的加载距离可能超过4GB,因此无法进行跳转/调用

当您使用-fPIC(位置独立代码)进行编译时,编译器将确保代码和本地数据引用是位置独立的,并在最坏情况/最大寻址模式(例如full 64b)下安排自身之外的调用/跳转

当您遇到此错误时,静态库无法跳转到共享库,上面的快捷方式已被采用。唯一的解决方案是使用-fPIC重新编译。(从技术上讲,32位跳转可能只有5个字节,但您需要9个字节[1个操作码+8用于addr];因此,汇编程序再聪明也无法解决这一问题——如果没有其他一些卑鄙的操作,比如使用INT指令来提供一个快速跳转)


现在,大多数东西都可以/应该用-fPIC编译,而不管它们是共享的-除非性能很重要。

当静态编译时,汇编指令将假定代码的某些位置,例如,任何跳转都在跳转/调用指令的4GB范围内。(假设64b x86)。共享库的加载距离可能超过4GB,因此无法进行跳转/调用

当您使用-fPIC(位置独立代码)进行编译时,编译器将确保代码和本地数据引用是位置独立的,并在最坏情况/最大寻址模式(例如full 64b)下安排自身之外的调用/跳转

当您遇到此错误时,静态库无法跳转到共享库,上面的快捷方式已被采用。唯一的解决方案是使用-fPIC重新编译。(从技术上讲,32位跳转可能只有5个字节,但您需要9个字节[1个操作码+8用于addr];因此,汇编程序再聪明也无法解决这一问题——如果没有其他一些卑鄙的操作,比如使用INT指令来提供一个快速跳转)

如今,大多数东西都可以/应该使用-fPIC编译,而不管是否共享,除非性能很重要。

必须使用
-fPIC
重新编译存档(
.a
)。必须使用
-fPIC
重新编译存档(
.a
)。
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

O_SRCS := 
CPP_SRCS := 
C_UPPER_SRCS := 
C_SRCS := 
S_UPPER_SRCS := 
OBJ_SRCS := 
ASM_SRCS := 
CXX_SRCS := 
C++_SRCS := 
CC_SRCS := 
OBJS := 
C++_DEPS := 
C_DEPS := 
CC_DEPS := 
LIBRARIES := 
CPP_DEPS := 
CXX_DEPS := 
C_UPPER_DEPS := 

# Every subdirectory with source files must be described here
SUBDIRS := \
. \
generic_d2s \