[gdal-dev] Compilation error

Vincent Schut schut at sarvision.nl
Fri Mar 28 06:30:04 EDT 2008


gary wrote:
> I did the configure --with-fPIC, though it didn't show up as an option. 
> Anyway, any idea why gdal isn't compiling?
> ---------------------------------------------------------------------
> 
<snip>

> /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o   
> -Wl,-soname -Wl,libgdal.so.1 -o .libs/libgdal.so.1.12.1
> /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: 
> /usr/local/lib/libjasper.a(jas_image.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/libjasper.a: could not read symbols: Bad value
> collect2: ld returned 1 exit status
> make[1]: *** [libgdal.la] Error 1
> make[1]: Leaving directory `/usr/local/src/gdal/gdal-1.5.1'
> make: *** [check-lib] Error 2
> suse:/usr/local/src/gdal/gdal-1.5.1 #

This means you need to compile *libjasper* with -fPIC. Otherwise gdal is 
not able to link to it. I think for gdal on x86_64, -fPIC is enabled by 
default.

Usually the right way to add -fPIC to a compilation process (if not 
offered by configure as a --with-fpic option) is to invoke configure as 
follows:

CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --with-your-options

configure will then pick up your custom cflags/cxxflags (in case it is 
c++, don't know it -fPIC applies to that but just to be sure) and will 
eventually add it's own cflags to it, thus creating makefiles that will 
invoke the compiler with the -fPIC flag.

Once you have recompiled jasper with -fPIC, you can probably run make in 
the gdal dir again and it will build fine (or until the next error :))

Cheers,
Vincent.


More information about the gdal-dev mailing list