Linker error with GCC?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Linker error with GCC?

Bugzilla from kyle.a.taylor@gmail.com
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?

Thanks, 

Kyle

----------
$ 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.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --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 --build=x86_64-redhat-linux
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; }
        else
          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;
}


_______________________________________________
Shapelib mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/shapelib
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Linker error with GCC?

Frank Warmerdam-2
On 11-02-07 07:06 PM, Kyle Taylor wrote:

> 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?
>
> Thanks,
>
> Kyle
>
> ----------
> $ gcc main.cc
>
> /tmp/ccltpct4.o: In function `main':
> main.cc:(.text+0x79): undefined reference to `SHPOpen'
> collect2: ld returned 1 exit status

Kyle,

Try:

   gcc main.c -lshp

You might possibly need to specify the directory in which case it would
be:

   gcc main.c -L/usr/lib64 -lshp

Note that shapelib is also easy to build on it's own from source.  I'm not
really a fan of it being included in distributions.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

_______________________________________________
Shapelib mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/shapelib
Loading...