Bug #25404 mysql_config need several issues corrected
Submitted: 4 Jan 2007 2:57 Modified: 15 Nov 2017 18:23
Reporter: Jonathan Miller Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:mysql-5.1 OS:Any
Assigned to: Kent Boortz CPU Architecture:Any

[4 Jan 2007 2:57] Jonathan Miller
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
[13 Feb 2007 22:45] Monty Taylor
I took a stab at this before I found this bug. So I'm going to commit a change that adds --libndbclient-libs and --libndbclient-cflags. I heartily welcome comments.
[13 Feb 2007 23:02] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/19813

ChangeSet@1.2428, 2007-02-13 21:02:17-02:00, mtaylor@qualinost.(none) +2 -0
  Added cflags and libs options to mysql_config for NdbApi programs. Bug #25404