List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:March 2 2000 5:40pm
Subject:Re: help with MySQL setup
View as plain text  
On Thu, Mar 02, 2000 at 06:50:20PM +0200, Uri Even-Chen wrote:
>I have so many problems in compiling my programs with mysql++. I have
>already installed mySQL and mysql++, but I didn't find information on
>how to compile files with it. I keep getting compilation errors, even
>after I added all the include library options -I, -L and -l. I'm not
>using any Makefile, but I compile everything from a script. I even can't
>compile your examples. my compilation command is (I tried every possible
>option):
>
>`/usr/bin/g++ -L/usr/lib/mysql -lmysqlclient -lmysql++ -I
>/usr/local/include/mysql++/ -I /usr/include/mysql/  simple1.cc`

Uri Even-Chen,

The problem is that you need to put the linker flags at the
end of your compile line.  This sounds ridiculous, and maybe
it is, but that is how the compiler tools work together.

Let me show you using the example line above, which will not
work.  This line, below, will work:

/usr/bin/g++ -I/usr/local/include/mysql++ -I/usr/include/mysql \
    simple1.cc -L/usr/lib/mysql -lmysql++ -lmysqlclient

This is not intuitive (why should it matter what in order you put
the flags?  Why should the flags go *after* the file name you are
compiling?  It also is not well-documented anywhere.  I think
everyone who has ever programmed in C on Unix can remember having
this trouble and being very frustrated.

Also, it is important in what order those -lxxxx flags are.  I
think of it this way:

    simple1.cc --(uses)--> -lmysql++ --(uses)--> -lmysqlclient

So you must have simple1.cc first, -lmysql++ second, and finally
-lmysqlclient.  Please note that this has nothing, really, to do
with MySQL - it is how the compiler tools are designed!

Good luck!

Tim
-- 
Tim Smith   < tim@stripped >  :MySQL Development Team:  Boone, NC  USA.
Thread
help with MySQL setupUri Even-Chen15 Feb
  • Re: help with MySQL setupsinisa15 Feb
    • Re: help with MySQL setupUri Even-Chen2 Mar
      • Re: help with MySQL setupsinisa3 Mar
    • still problems with mysql++Uri Even-Chen2 Mar
      • Re: still problems with mysql++Thimble Smith3 Mar
    • Re: help with MySQL setupTonu Samuel3 Mar
    • Re: still problems with mysql++Tonu Samuel3 Mar
    • Re: still problems with mysql++Uri Even-Chen3 Mar
    • Re: still problems with mysql++Tonu Samuel3 Mar
    • Re: another bug report with mysql++Uri Even-Chen5 Mar
      • Re: another bug report with mysql++sinisa5 Mar
        • Re: segmentation fault with mysql++Uri Even-Chen5 Mar
          • Re: segmentation fault with mysql++sinisa6 Mar
        • Re: segmentation fault with mysql++Uri Even-Chen7 Mar
          • Re: segmentation fault with mysql++Thimble Smith7 Mar
  • Re: help with MySQL setupUri Even-Chen1 Mar
  • Re: help with MySQL setupTonu Samuel1 Mar
  • Re: help with MySQL setupUri Even-Chen2 Mar
    • Re: help with MySQL setupsinisa2 Mar
    • Re: help with MySQL setupThimble Smith2 Mar
  • Re: help with MySQL setupUri Even-Chen2 Mar
    • Re: help with MySQL setupsinisa2 Mar