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.