Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
83 Views

.text can not be used when mking a shared object

Jump to solution

I am working on the project of porting numerous codes from f77 TruUnix to Linux f90 64bit.   Really struggling with some of this.   The contempt28 program uses the shared library and pgplot to create plotting files.   The contempt28 is integrated with using the pgplot with the shared libraries.

I am trying to make this work have stalled getting the shared library built.The build order is pgplot (done), the shlib(shared library) and link to pgplot.  Then build contempt28 and link to shlib and pgplot.   

When compiling a shared library and linking to PGPLOT as shown here in the Makefile, I get the following error.   The libpgplot.a was built in the pgplot build.

/opt/intel/bin/ifort -debug -shared -fPIC -align dcommons -real-size 64 -warn nousage -o pgprompt.so pgprompt.f -L/rxe/source/shlib/v21_cp03/v2.1.cp03/pgplot -lpgplot -lX11
ld: /rxe/source/shlib/v21_cp03/v2.1.cp03/pgplot/libpgplot.a(xwdriv.o): relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
/rxe/source/shlib/v21_cp03/v2.1.cp03/pgplot/libpgplot.a: could not read symbols: Bad value
make: *** [pgprompt.so] Error 1

SHLIB MAKEFILE:

FC=/opt/intel/bin/ifort
CC=/opt/intel/bin/icc
CFLAGS=-g -shared -fPIC
FFLAGS=-debug -shared -fPIC -align dcommons -real-size 64 -warn nousage
LFLAGS=-debug -shared -fPIC -align dcommons -real-size 64 -warn nousage
PGPLOT_DIR=/rxe/source/shlib/v21_cp03/v2.1.cp03/pgplot

all: interfaces.so hpgl_routines.so system.so pgprompt.so datey2k.so

interfaces.so : interfaces.c
 $(CC) $(CFLAGS) -o interfaces.so interfaces.c

hpgl_routines.so : hpgl_routines.f
 $(FC) $(FFLAGS) -o hpgl_routines.so hpgl_routines.f

system.so : system.f
 $(FC) $(FFLAGS) -o system.so system.f

pgprompt.so : pgprompt.f
 $(FC) $(LFLAGS) -o pgprompt.so pgprompt.f -L${PGPLOT_DIR} -lpgplot -lX11
 
datey2k.so : datey2k.f
 $(FC) $(FFLAGS) -o datey2k.so datey2k.f
 
mktemp.o: mktemp.f
 $(FC) $(FFLAGS) -o mktemp.o mktemp.f

 

The Makefile is created by running a shell script makemake with three parameters

$1= /rxe/source/pgplot $2= Linux  $3 f77_gcc  .  When the Makefile is created, I correct the f77 to correct path to ifort.

 

 

Thanks in advance for help.

0 Kudos

Accepted Solutions
Highlighted
Black Belt
83 Views

I don't think that many people would have the patience to read through almost a thousand lines of makefile text and make output in a help request. You can attach files of any type if you enclose one or more of them in a Zip or compressed tar (*.tgz) file.

I believe that your problems were caused by the static library libpgplot.a having been built without the -fPIC compiler flag. If so, when the shared library is being linked, the linker finds some objects with PIC and the rest of the objects with PDC (position dependent code), and gives up.

View solution in original post

0 Kudos
2 Replies
Highlighted
Black Belt
84 Views

I don't think that many people would have the patience to read through almost a thousand lines of makefile text and make output in a help request. You can attach files of any type if you enclose one or more of them in a Zip or compressed tar (*.tgz) file.

I believe that your problems were caused by the static library libpgplot.a having been built without the -fPIC compiler flag. If so, when the shared library is being linked, the linker finds some objects with PIC and the rest of the objects with PDC (position dependent code), and gives up.

View solution in original post

0 Kudos
Highlighted
New Contributor I
83 Views

mecej4:

Initially I was not able to attach the Makefile.  Then I realized I could add a .txt file extension, and the attachment was successful.  Thanks for you patience.

I missed adding the -fPIC to the SHARED_LIB var in the pgplot Makefile.  .  Thank you!

 

0 Kudos