Description:
Hi,
Kent asked that I open a bug on mysql_config from these emails.
"Jonathan Miller" <jmiller@mysql.com> writes:
<snip>
> Problem #2
> ->
> -> A slash is missing, should be
> ->
> -> CFLAGS="$CFLAGS "`mysql_config --cflags`
> -> CFLAGS="$CFLAGS "`mysql_config --include/`storage/ndb
> -> CFLAGS="$CFLAGS "`mysql_config --include/`storage/ndb/ndbapi
> -> CFLAGS="$CFLAGS "`mysql_config --include/`storage/ndb/mgmapi
> ->
>
> The problem with the above is 2 fold.
>
> 1) CFLAGS="$CFLAGS "`mysql_config --include/`storage/ndb/ndbapi should be
> CFLAGS="$CFLAGS "`mysql_config --include`/storage/ndb/ndbapi
>
> 2) That then provides
> -I/data1/mysql-5.1/include/mysql/storage/ndb/ndbapi
> This would be okay if that is where the NDB API files were located,
> but they are not. The are located in
> /data1/mysql-5.1/storage/ndb/ndbapi
>
> There is nothing that in mysql_config that allows me to pull just
> /data1/mysql-5.1
>
> What would be the correct way to resolve this without hard coding it in?
<snip>
> -> Yes, you are right, so I now favor (B) above ;-)
>
> So how do we get be done? ;-)
I will look into this, but please write a bug report about it so it doesn't get lots. And assign me and put Mads as lead.
And in the mean time hard code it ;-)
kent
> I need a little help. I am trying to get a test to compile and link
> using NDBAPI.
>
> Problem #1
>
> When I use a 5.1.15 mysql_config I get the following error.
>
> /home/ndbdev/jmiller/builds/include/mysql/mysql.h:125: error: ISO C++
> does not support â?~long longâ?T
> make: *** [Atomics.o] Error 1
>
> If I use a 4.1.19 mysql_config, it compiles without error.
>
> 4.1.19 mysql_config
>
> Options:
> --cflags [-I/usr/include/mysql -g -pipe
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4
> -fasynchr onous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
> -D_LARGEFILE_SOURCE -fno-strict-aliasing]
>
> 5.1.15 mysql_config
>
> Options:
> --cflags [-I/home/ndbdev/jmiller/builds/include/mysql
> -pedantic]
>
> So I thought it might be some of the missing --cflags, so I added them
> to the Makefile.
>
> MYSQL_CONFIG = mysql_config
>
> CXXFLAGS = `$(MYSQL_CONFIG) --cflags` -g -pipe
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4
> -D_GNU_SOURCE
> -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing
>
> And it complied and linked. How do I get these flags inside
> mysql_config --cflag?
In my opinion "mysql_config" should only output what needs to be
*added* to use our API, not the complete build environment. So both "mysql_config" above specify "too much", and I think you should add what your application needs, then add what "mysql_config" output.
> Problem #2
>
> According to our documentation
>
> http://dev.mysql.com/doc/ndbapi/en/getting-started-compiler-options.ht
> ml
>
> It is necessary to add the subdirectory paths explicitly, so that
> adding all the needed compile flags to the CXXFLAGS shell variable
> should look something like this:
>
> CFLAGS="$CFLAGS "`mysql_config --cflags` CFLAGS="$CFLAGS
> "`mysql_config --include`storage/ndb CFLAGS="$CFLAGS "`mysql_config
> --include`storage/ndb/ndbapi CFLAGS="$CFLAGS "`mysql_config
> --include`storage/ndb/mgmapi
A slash is missing, should be
CFLAGS="$CFLAGS "`mysql_config --cflags`
CFLAGS="$CFLAGS "`mysql_config --include/`storage/ndb
CFLAGS="$CFLAGS "`mysql_config --include/`storage/ndb/ndbapi
CFLAGS="$CFLAGS "`mysql_config --include/`storage/ndb/mgmapi
But it is silly to document how to work around a bug in our "mysql_config" script, it should know about all our API's. Either we should
(A) If cluster is compiled in, let "mysql_config" output all
-I<path> needed to use it.
(B) Add a flag to "mysql_config", "--ndbapi"
(C) Let a "make install" put the ndb API libraries in
$prefix/lib/mysql, no need for the extra levels.
I prefer (C).
> But this does not produce the desired results. What is the correct way
> to include extra includes in the Makefile?
>
> Problem #3
>
> Not sure this is a problem or not, but thought I would throw it in
> while I was going, could you review
> http://dev.mysql.com/doc/ndbapi/en/getting-started-linker-options.html
> and make sure that this is correct?
>
> NDB API applications must be linked against both the MySQL and NDB
> client libraries. The NDB client library also requires some functions
> from the mystrings library, so this must be linked in as well.
>
> The necessary linker flags for the MySQL client library are returned
> by mysql_config --libs. For multithreaded applications you should use
> the --libs_r instead:
>
> $ mysql_config --libs_r
> -L/usr/local/mysql-5.1/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt
> -lnsl -lm -lpthread -L/usr/lib -lssl -lcrypto
>
> To link an NDB API application, it is necessary to add -lndbclient and
> -lmystrings to these options. Adding all the required linker flags to
> the LDFLAGS variable should look something like this:
>
> LDFLAGS="$LDFLAGS "`mysql_config --libs_r` LDFLAGS="$LDFLAGS
> -lndbclient -lmystrings"
Yes, you are right, so I now favor (B) above ;-)
> Thanks for the help! I am very weak when it comes to Make System.
And I'm very weak at the NDB client API usage, but I will soon learn!
I'm just working on "mysql_config", so your timing was good :-)
> Current Makefile:
<snip>
For being "weak when it comes to Make System" you are doing fine! :-)
Sorry for not that straight answers,
kent
How to repeat:
see above