Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

linking problem on Xeon cpu

ldezsenyi
Beginner
243 Views

Hello!

I've triedto link my program with IPP libraries statically, but the linker had problem with relocation. I use the em64t package for linux.

Thelinker output:

g++ -shared -fPIC -Wall -D_LINUX -D_STATIC -O3 -I/opt/intel/ipp/5.1/em64t/include -I/netavis/JAVA/jdk1.6.0_01/include -I/netavis/JAVA/jdk1.6.0_01/include/linux -o libNativeMotionDetector.so motiondetector.cpp detectorctrl.cpp opregion.cpp collidetector.cpp noiseestimator.cpp propertylist.cpp -L/home/motdet/jpegcodec -L/opt/intel/ipp/5.1/em64t/lib -lippjemergedem64t -lippjmergedem64t -lippcvemergedem64t -lippcvmergedem64t -lippiemergedem64t -lippimergedem64t -lippsemergedem64t -lippsmergedem64t -lippcoreem64t -lJPEGCodec
/usr/bin/ld: /opt/intel/ipp/5.1/em64t/lib/libippimergedem64t.a(pisum16sm7as.o): relocation R_X86_64_PC32 against `m7_ownpis_Sum_16s_C1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [libNativeMotionDetector.so] Error 1

and the Makefile:

INCLUDE_PATH := /opt/intel/ipp/5.1/em64t/include /netavis/JAVA/jdk1.6.0_01/include

/netavis/JAVA/jdk1.6.0_01/include/linux

LIBRARY_PATH := /home/motdet/jpegcodec /opt/intel/ipp/5.1/em64t/lib
CC := g++
CCFLAGS := -fPIC -Wall -D_LINUX -D_STATIC -O3 $(addprefix -I,$(INCLUDE_PATH))
LDFLAGS := $(addprefix -L,$(LIBRARY_PATH))

LIBNAME := libNativeMotionDetector.so
SOURCE := motiondetector.cpp detectorctrl.cpp opregion.cpp collidetector.cpp
noiseestimator.cpp propertylist.cpp
IPPLIB := ippjemergedem64t ippjmergedem64t ippcvemergedem64t ippcvmergedem64t
ippiemergedem64t ippimergedem64t ippsemergedem64t ippsmergedem64t
ippcoreem64t

$(LIBNAME) : $(SOURCE)
$(CC) -shared $(CCFLAGS) -o $@ $^ $(LDFLAGS) $(addprefix -l,$(IPPLIB)) -lJPEGCodec

.PHONY : clean
clean:
-rm $(LIBNAME)

The last shared library("libJPEGCodec")to link is statically linked too. This uses the

ippi,ipps,ippj,ippcc emerged and merged libraries, and make runs without any error message.

More details:

CPU: Intel Xeon CPU 5110 @ 1.60GHz

GCC: 3.4.6 (Red Hat 3.4.6-3)

System: Linux 2.6.9-42 x86_64

Have you any idea what is the cause ofthe problem?

Thanks inadvance

Laci


0 Kudos
2 Replies
Vladimir_Dudnik
Employee
243 Views

Hello,

you ned to use the followinglinker option:

--pic-executable
Create a position independent executable. This is currently only supported on ELF platforms. Position independent executables are similar to shared libraries in that they are relocated by the dynamic linker to the virtual address the OS chooses for them (which can vary between invocations). Like normal dynamically linked executables they can be executed and symbols defined in the executable cannot be overridden by shared libraries.

Regards,
Vladimir

0 Kudos
ldezsenyi
Beginner
243 Views

Thanks Vladimir!

It works fine...

Regards

Laci

0 Kudos
Reply