[Shapelib] Linker error with GCC?

Kyle Taylor kyle.a.taylor at gmail.com
Mon Feb 7 19:06:57 EST 2011

Hey all,

I stumbled upon shapelib the other day and am really excited about the
project.  It sounds like a handy lib.  I'm trying to get a feel for it by
playing around with GCC.  Trouble is, GCC (Fedora 14) is having trouble and
can't link against shapelib.  shapelib was installed directly out of the YUM
repositories, and its sitting pretty in /usr/lib64/.  Am I just looking over
something really dumb, or are other people having similar trouble?



$ gcc main.cc

/tmp/ccltpct4.o: In function `main':
main.cc:(.text+0x79): undefined reference to `SHPOpen'
collect2: ld returned 1 exit status

$ gcc -v

Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)

$ ldconfig -p | grep libshp
        libshp.so.1 (libc6,x86-64) => /usr/lib64/libshp.so.1
        libshp.so (libc6,x86-64) => /usr/lib64/libshp.so

$ cat main.cc

#include <libshp/shapefil.h>
#include <stdioh.h>

int main(int argc, char *argv[])
        char            PATH[FILENAME_MAX_LEN];
        SHPHandle       shapefile;

        /* read program argv[1] specifying shapefile */

        if(argc < 2)
          { printf("%s requires a filepath argument to the .SHP file you
wish to analyse.\n", argv[0]); return -1; }
          strncpy(PATH, argv[1], sizeof(PATH));

        /* attempt to open shapefile */

        if(!(shapefile = SHPOpen(PATH, "rb")))
          { printf("could not open %s for reading.  Does the file exist?\n",
PATH); return -1; }

        return 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/shapelib/attachments/20110207/5d10051a/attachment.htm 

More information about the Shapelib mailing list