Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

PIC /error: relocation R_X86_64_32S against `vtable for hit' can not be used when making a shared object; recompile with -fPIC

Daniel_N_1
Beginner
710 Views

I'm newbie with Linux and I'm having trouble with compiling a make file which works well in a 32-bit machine. I didn't write this program but I need it to work to use its functionalities. My machine is 64-bit and I get the following message error:

cd pmtTools; make

make[1]: Entering directory `/home/daniel/Documents/Master_thesis/data_Daniel-Thomas/photondet/trace/PMTSignalsAnalysis/pmtTools'

g++ -shared -L/home/root/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -o libPmtTools.so hit.o event.o waveform.o readLeCroyBinary.o pmtToolsDict.o

/usr/bin/ld: hit.o: relocation R_X86_64_32S against `vtable for hit' can not be used when making a shared object; recompile with -fPIC

hit.o: could not read symbols: Bad value

collect2: ld returned 1 exit status

make[1]: *** [libPmtTools.so] Error 1

make[1]: Leaving directory `/home/daniel/Documents/Master_thesis/data_Daniel-Thomas/photondet/trace/PMTSignalsAnalysis/pmtTools'

make: *** [all] Error 2

I've been trying to solve the problem by using this website but I don't get the program to work... http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3I'm not used to makefiles and that's why I don't manage to modify the makefiles properly to PIC compile the shared libraries. I added globally the flag 'export CXXFLAGS=$CXXFLAGS -fPIC' but it didn't work. I'm just completely lost.

Here are the make files (two make files and one which calls them).

CXX = $(shell $(ROOTCONFIG) --cxx)

LD = $(shell $(ROOTCONFIG) --ld)

CFLAGS = $(shell $(ROOTCONFIG) --cflags)

LIBS = $(shell $(ROOTCONFIG) --libs)

SOFLAGS = -shared

CINTSRCS = event.cc hit.cc

CINTINCS = event.h hit.h

OBJS = hit.o event.o waveform.o readLeCroyBinary.o pmtToolsDict.o

LIBPMTTOOLS = libPmtTools.so

all: $(LIBPMTTOOLS)

          export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/Documents/Master_thesis/data_Daniel-Thomas/photondet/trace/PMTSignalsAnalysis/pmtTools

$(LIBPMTTOOLS): $(OBJS)

          $(LD) $(SOFLAGS) $(LIBS) -o $@ $(OBJS)

%.o: %.cc

          $(CXX) $(CFLAGS) -c -o $@ $<

pmtToolsDict.cc: $(CINTSRCS) $(CINTINCS) pmtToolsLinkDef.h

         @echo "Generating dictionary pmtToolsDict..."

         $(ROOTCINT) -f pmtToolsDict.cc -c -p $(CINTINCS) pmtToolsLinkDef.h

clean:

       rm -f pmtToolsDict.cc pmtToolsDict.h $(LIBPMTTOOLS) $(OBJS)

dox:

      rm -rf html

     $(DOXYGEN) pmtTools.dox

------------------------------------------2---------------------------------------------

ROOTCONFIG = $(ROOTSYS)/bin/root-config

CXX = $(shell $(ROOTCONFIG) --cxx)

LD = $(shell $(ROOTCONFIG) --ld)

CFLAGS = $(shell $(ROOTCONFIG) --cflags) -I../pmtTools

LIBS = $(shell $(ROOTCONFIG) --libs)# -L../pmtTools -lpmtTools

OBJS = analysis.o

SHARED = ../pmtTools/libPmtTools.so

EXE = analysis.exe

all: $(EXE)

$(EXE): $(OBJS) $(SHARED)

      $(LD) $(LIBS) -o $@ $(OBJS) $(SHARED)

$(SHARED):

      cd ../pmtTools; make

%.o: %.cxx

      $(CXX) $(CFLAGS) -c -o $@ $<

test: test.cxx $(SHARED)

      $(CXX) $(CFLAGS) -c -o test.o test.cxx

      $(LD) $(LIBS) -o test.exe test.o $(SHARED)

clean:

        rm -f $(EXE) $(OBJS) test.o test.exe

-----------------------------------------3---------------------

all:

         cd pmtTools;     make

         cd analysis;      make

clean:

         cd pmtTools;     make clean

         cd analysis;      make clean

Hope that someone can help me. Thanks in advance!! Daniel

0 Kudos
4 Replies
Georg_Z_Intel
Employee
710 Views
Hello, it might be better to ask the author of the program directly as it looks more like a project configuration issue. One thing you might try, though: $ make CFLAGS='-fpic' CXXFLAGS are not used in your Makefile. Best regards, Georg Zitzlsberger
0 Kudos
SergeyKostrov
Valued Contributor II
710 Views
[ DUPLICATE ] Removed. Sorry about this.
0 Kudos
SergeyKostrov
Valued Contributor II
710 Views
>>My machine is 64-bit and I get the following message error: >> >>cd pmtTools; make >> >>make[1]: Entering directory `/home/daniel/Documents/Master_thesis/data_Daniel-Thomas/photondet/trace/PMTSignalsAnalysis/pmtTools' >> >>g++ -shared -L/home/root/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics >>-lMathCore -lThread -pthread -lm -ldl -rdynamic -o libPmtTools.so hit.o event.o waveform.o readLeCroyBinary.o pmtToolsDict.o >> >>/usr/bin/ld: hit.o: relocation R_X86_64_32S... I could only assume that you're accidentally mixing 32-bit and 64-bit objects or libraries when trying to build a 64-bit application. I agree with Georg that it looks like a project configuration problem with a make file and the problem happens when linking object or libraries.
0 Kudos
SergeyKostrov
Valued Contributor II
710 Views
Here are a couple of more notes: The list of objects files is: ... OBJS = hit.o event.o waveform.o readLeCroyBinary.o pmtToolsDict.o ... and a 2nd linker error is also related to: ... hit.o: could not read symbols: Bad value ... Is there a possibility that hit.o is corrupted?
0 Kudos
Reply