10/26/03 12:37:28 AM, Patrik Fimml <[EMAIL PROTECTED]> wrote: > >Well, I tried it many times... here is the last: > >gcc -L/usr/local/lib/mysql -lmysqlclient -lnsl -lm -o rpgservices conn.o io.o >main.o >main.o(.text+0x80): In function `main': >: undefined reference to `mysql_connect' >collect2: ld returned 1 exit status
Patrick, you have a link-ordering problem. I can't quite determine where -lmysqlclient should be in your link line, because I don't know where function 'main' is. An app of 'hello world' complexity might look like so: gcc test.c -W -Wall -g -L/usr/local/lib/mysql -lmysqlclient -lz -o /usr/local/dev/build/test Wherein 'main' resides in test.c and the output is placed in /usr/local/dev/build/test In general, the library that is being linked *to* must follow the library that is doing the linking (so that the unresolved symbol can be found in a later file, and subsequently resolved) in the command line to the linker/compiler. If your calls are in some library, or some object file (conn.o? io.o? then -lmysqlclient must be *after* them in the link line.) Since -lmysqlclient is a third party library, depending on nothing of your own manufacture, it should probably come at the very end of your link line (although note that it does, usually, depend on -lz, which should follow it). If this is unhelpful, please feel free to email me details pertinent to your full development environment, and perhaps we can delve further. -bluejack -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]