2013-05-15 1 views
0

eclipse를 사용하여 redhat에서 g ++ 64 비트로 컴파일.정적 (.a) 라이브러리를 공유 (.so) 라이브러리와 연결하여 "로컬 심볼에 대해 재배치 R_X86_64_32S; -fPIC로 다시 컴파일"

컴파일 오류 : ../lib-EL5-64bit/libskd3_clnt_30134500.a(skd_clnt.o) : 공유 객체를 만들 때 '로컬 기호'에 대한 재배치 R_X86_64_32S 사용할 수 없습니다;

내가 시도한 것 -fPIC를 링커 플래그와 함께 C++ 컴파일러 플래그에 추가했습니다. 이미 컴파일러 플래그에 존재했습니다. 이제 막 g ++ 바로 다음으로 이동하고 목록의 끝에 있습니다.

나는 -fPIC으로 컴파일하기로 .a 라이브러리의 창조자를 요청했습니다 그것은 여전히 ​​같은 오류

자신의 라이브러리를 -fPIC으로 컴파일되었는지 확인하는 방법은 없나요을 준다? 오류 메시지가 내 .so -fPIC을 컴파일해야한다고 나타내지 만, .a 파일을 -fPIC과 함께 컴파일해야합니까? 그 밖의 무엇을 확인할 수 있습니까?

################################################################################ 
# 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: [email protected]' 
    @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: [email protected]' 
    @echo ' ' 

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

.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"[email protected]" "$<" 
    @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"[email protected]" "$<" 
    @echo 'Finished building: $<' 
    @echo ' ' 

objects.mk

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

USER_OBJS := 

LIBS := -lBB_IO_lib.0.1 -lskd3_clnt_30134500 -lcryptopp 

출처 : 여기에

은 (일식에 의해 생성 된 자동) 만들기 파일

만들기 파일입니다 .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 \ 
+0

아카이브 ('.a')는'-fPIC'로 다시 컴파일해야합니다. –

답변

3

정적으로 컴파일 할 때 어셈블러 명령어는 코드의 지역성에 대한 특정 사항을 가정합니다. 모든 점프는 점프/호출 명령어의 4GB 이내입니다. (64b x86을 가정). 공유 라이브러리는 4GB보다 멀리로드 될 수 있으므로 점프/호출이 적합하지 않습니다.

-fPIC (위치 독립적 코드)로 컴파일 할 때 컴파일러는 코드 및 로컬 데이터 참조가 독립적 인 위치에 있는지 확인하고 최악/최대 주소 지정 모드에서 자체 외부에서 호출/건너 뛰기를 수행하도록합니다 예 : 전체 64b).

이 오류가 발생하면 정적 라이브러리는 공유 라이브러리로 이동할 수 없습니다. 위의 바로 가기가 사용되었습니다. 유일한 해결책은 -fPIC를 사용하여 다시 컴파일하는 것입니다. (기술적으로 32 비트 점프는 5 바이트 일 수 있지만 9 바이트 [addr에 대해 1 개의 opcode + 8]가 필요하므로 INT 명령을 사용하는 것과 같은 다른 비겁한 연산없이 어셈블러의 영리성을 극대화 할 수는 없습니다 짧은 핸드 점프 제공).

성능이 중요하지 않으면 요즘 대부분은 모든 것이 공유 될 수 있는지 여부에 관계없이 -fPIC으로 컴파일 될 수 있습니다.

관련 문제