LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Can someone help me understand how to fix my recompile with -fPIC error ? (https://www.linuxquestions.org/questions/linux-software-2/can-someone-help-me-understand-how-to-fix-my-recompile-with-fpic-error-778061/)

Bascom49 12-25-2009 12:23 PM

Can someone help me understand how to fix my recompile with -fPIC error ?
 
I'm setting up a Mapserver installation on a 64 bit Linux machine and get the following error during make :

/projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/shp_vsi.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigeraltname.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerarealandmarks.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigercompletechain.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerentitynames.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerfeatureids.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerfilebase.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigeridhistory.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerkeyfeatures.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerlandmarks.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigeroverunder.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerpip.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerpoint.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerpolychainlink.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerpolygoncorrections.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerpolygoneconomic.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerpolygon.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerspatialmetadata.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigertlidrange.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerzerocellid.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerzipcodes.o /projects/gdal-1.6.3/ogr/ogrsf_frmts/o/.libs/tigerzipplus4.o ./ogr/.libs/ogrgeometryfactory.o ./ogr/.libs/ogrpoint.o ./ogr/.libs/ogrcurve.o ./ogr/.libs/ogrlinestring.o ./ogr/.libs/ogrlinearring.o ./ogr/.libs/ogrpolygon.o ./ogr/.libs/ogrutils.o ./ogr/.libs/ogrgeometry.o ./ogr/.libs/ogrgeometrycollection.o ./ogr/.libs/ogrmultipolygon.o ./ogr/.libs/ogrsurface.o ./ogr/.libs/ogrmultipoint.o ./ogr/.libs/ogrmultilinestring.o ./ogr/.libs/ogr_api.o ./ogr/.libs/ogrfeature.o ./ogr/.libs/ogrfeaturedefn.o ./ogr/.libs/ogrfeaturequery.o ./ogr/.libs/ogrfeaturestyle.o ./ogr/.libs/ogrfielddefn.o ./ogr/.libs/ogrspatialreference.o ./ogr/.libs/ogr_srsnode.o ./ogr/.libs/ogr_srs_proj4.o ./ogr/.libs/ogr_fromepsg.o ./ogr/.libs/ogrct.o ./ogr/.libs/ogr_opt.o ./ogr/.libs/ogr_srs_esri.o ./ogr/.libs/ogr_srs_pci.o ./ogr/.libs/ogr_srs_usgs.o ./ogr/.libs/ogr_srs_dict.o ./ogr/.libs/ogr_srs_panorama.o ./ogr/.libs/ogr_srs_erm.o ./ogr/.libs/swq.o ./ogr/.libs/ogr_srs_validate.o ./ogr/.libs/ogr_srs_xml.o ./ogr/.libs/ograssemblepolygon.o ./ogr/.libs/ogr2gmlgeometry.o ./ogr/.libs/gml2ogrgeometry.o -Wl,-rpath -Wl,/usr/local/lib -Wl,-rpath -Wl,/usr/local/lib /usr/local/lib/libtiff.so /usr/local/lib/libjpeg.so /usr/local/lib/libpng12.so -L/usr/local/lib /usr/local/lib/libcurl.so -L/usr/kerberos/lib64 -lidn -lrt -lssl -lcrypto -ldl -lz -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2 -L/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crtn.o -Wl,-soname -Wl,libgdal.so.1 -o .libs/libgdal.so.1.13.3
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libgdal.la] Error 1
make[1]: Leaving directory `/projects/gdal-1.6.3'
make: *** [check-lib] Error 2


If someone could explain to me which library is the problem and how to recompile the library I would be most appreciative.

Thanks in advance

knudfl 12-25-2009 02:07 PM

Welcome to LQ.
Quote:

/usr/bin/ld: /usr/local/lib/libz.a(crc32.o):
relocation R_X86_64_32 against ........
GDAL must link against ' libz.so '. And it will, if present.

So what happened to your system zlib ?
Example 32 - bit Linux :
ls -l /usr/lib/libz*
/usr/lib/libz.a*
/usr/lib/libz.so -> libz.so.1.2.3*
/usr/lib/libz.so.1 -> libz.so.1.2.3*
/usr/lib/libz.so.1.2.3 -> ../../lib/libz.so.1.2.3*

Which Linux are you using ?
The development package zlib1-dev or something like that
would be available in your 'Package Manager'.
Or should be build with : ./configure --shared
( The --shared option is a zlib option only, most other
libs use --enable-shared. .. Or "shared" is default.)
The command ' ./configure --help ' shows these options.
.....

Bascom49 12-25-2009 05:01 PM

-fPIC
 
Thanks for the reply.

zlib has been updated

root@inf [/projects]# ls -l /usr/lib/libz*
-rwxr-xr-x 1 root root 92598 Jan 9 2007 /usr/lib/libz.a*
lrwxrwxrwx 1 root root 13 Dec 23 13:44 /usr/lib/libz.so -> libz.so.1.2.3*
lrwxrwxrwx 1 root root 13 Jan 9 2007 /usr/lib/libz.so.1 -> libz.so.1.2.3*
-rwxr-xr-x 1 root root 73580 Jan 9 2007 /usr/lib/libz.so.1.2.3*

I'm running centos linux, 64 bit.

The output gave the direction to relink using -fPIC. Is this something I can do globally, so that I do not have the same problem with other files ?

And how and where would I use the -fPIC option.

I'm more familiar with gentoo and have to admit that I'm feeling somewhat lost with installing packages on centos.

knudfl 12-26-2009 05:57 AM

Use the -fPIC option ..

You don't .. I guess
unless compiling a file.c , you have just written,
and want to use it for a shared library.

Long story ..
The " gdal error " in question just tells, that whoever
created that odd zlib in /usr/local/ forgot to use an
option creating "shared object".
Short : 'forgot -fPIC'

If you have more than one file.c or a library with
many files, you would probably always use a makefile
or autotools.

Libraries .. shared , static , and about fpic.
http://www.sunmanagers.org/archives/1995/1602.html

http://en.wikipedia.org/wiki/Shared_...ared_libraries

http://www.yolinux.com/TUTORIALS/Lib...ndDynamic.html

http://tldp.org/HOWTO/Program-Librar...libraries.html

http://www.ibm.com/developerworks/li...ies/index.html

http://sourceware.org/ml/glibc-linux.../msg00067.html

http://sourceware.org/ml/glibc-linux.../msg00068.html
.....


All times are GMT -5. The time now is 05:45 PM.