On 7/17/07, Benoit SIGOURE <address@hidden> wrote:
On Jul 17, 2007, at 8:22 PM, Damian Montaldo wrote:
> Hi, i'm having some problems to include mysql.h when i compile C
> source code.
Hello Damian,
>
> I'm using this macro
> http://autoconf-archive.cryp.to/ax_lib_mysql.html
> to find the path to mysql.h in a Debian Linux and work fine.
>
> $ ./configure
> ...
> checking for mysql_config... /usr/bin/mysql_config
> checking for MySQL libraries... yes
> ...
>
> When i run configure it generates this line in the Makefile file:
>
> MYSQL_CFLAGS = -I/usr/include/mysql -DBIG_JOINS=1
> MYSQL_CONFIG = /usr/bin/mysql_config
> MYSQL_LDFLAGS = -L/usr/lib/mysql -lmysqlclient
> MYSQL_VERSION = 5.0.32
> [...]
> But when i run make it doesn't include the MYSQL_CFLAGS so it's
> imposible to resolve this #include <mysql.h>
This macro provides you with the flags required to use MySQL in your
builds but it does not actually enforce them. And this is a sane
behavior. So now, you simply need to use these flags whenever you
need them, eg:
Yes, you're right. Now I understand why.
May be you want to compile different source files with different
include using different macros.
bin_PROGRAMS = mysqlcli
mysqlcli_SOURCES = ...
mysqlcli_CFLAGS = $(MYSQL_CFLAGS) $(AM_CFLAGS)
(don't forget to add the AM_*flags in the target-specific_*FLAGS)
Or simply...
bin_PROGRAMS = mysqlcli
mysqlcli_SOURCES = ...
AM_CFLAGS = $(MYSQL_CFLAGS)
... if you don't already use AM_CFLAGS and all the targets of this
Makefile.am must use $(MYSQL_CFLAGS). If you already use AM_CFLAGS,
then simply use `+=' instead of `='.
Thanks this really help me but I have another question about it:
I choose the first option because it looks more declarative and i have
this other problem.
Makefile.am:
bin_PROGRAMS = clumon
clumon_SOURCES = clumon.c
# set the include path found by configure
INCLUDES= $(all_includes)
# the library search path.
clumon_LDFLAGS = $(all_libraries) $(MYSQL_LDFLAGS)
clumon_CFLAGS = $(MYSQL_CFLAGS)
clumon_DEPENDENCIES = -I/usr/local/include -I/usr/include/mysql