Compile & Link error
Gene Holmerud
plug-discuss@lists.plug.phoenix.az.us
Sat, 23 Mar 2002 16:20:28 -0700
From: Gontran <gontran@gontran.net>
To: plug-discuss@lists.plug.phoenix.az.us
Subject: Re: Compile & Link error
Send reply to: plug-discuss@lists.plug.phoenix.az.us
<mailto:plug-discuss-request@lists.plug.phoenix.az.us?subject=subscribe>
<mailto:plug-discuss-request@lists.plug.phoenix.az.us?subject=unsubscribe>
Date sent: Sat, 23 Mar 2002 01:19:42 -0700
> * Gene Holmerud (geneous@bigfoot.com) wrote:
> > I'm trying to compile & link an example for mysql access from C code
> > using the command:
> >
> > gcc -L/usr/local/mysql/lib -I/usr/local/mysql/include -o select \
> > select.c -lmysql -lnsl -lsocket
> >
> > I get error messages:
> >
> > select.c: In function `main':
> > select.c:5: warning: return type of `main' is not `int' <-OK
> > /usr/bin/ld: cannot find -lmysql
> > collect2: ld returned 1 exit status
> >
> > I looked in /usr/local/mysql/lib and saw *.a's, so figured I was OK
> > that way. If I omit the -lmysql in the command, it doesn't object to
> > the -lnsl, but fails on -lsocket. What am I missing?
>
> believe you are looking for '-lmysqlclient' instead of '-lmysql'. I
> don't believe you need a socket library linked ... sockets are part of
> the glibc (to the best of my understanding). Looks ok otherwise.
>
> hth,
> Gontran
Thanks. The gcc command came out of O'reilly book "MySQL & mSQL".
After sending this, I kept looking and found libmysqlclient.a,
leading to your answer. And I do have glibc ver 2.2.4 (plus devel
pkg) installed. Great, except without the -lsocket param, I get
unresolved references to 'compress' and 'uncompress' from a mysqllib
routine. I found many references to those routines in many lib*.a's
so they should be resolved somewhere!, shouldn't they?
Gene