Bug #38608 Connector C++ compilation fails on Mac OSX
Submitted: 6 Aug 2008 17:33 Modified: 8 Aug 2008 6:39
Reporter: Giuseppe Maxia Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / C++ Severity:S1 (Critical)
Version:1.0.0.preview OS:MacOS (10.5)
Assigned to: CPU Architecture:Any
Tags: Compilation, fail, mac osx

[6 Aug 2008 17:33] Giuseppe Maxia
Description:
Compilation fails on Mac OSX 10.5

$ cmake .
-- mysql_config was found /usr/local/mysql/bin/mysql_config
-- MySQL Include dir: /usr/local/mysql/include
-- MySQL Library dir: /usr/local/mysql/lib
-- MySQL CFLAGS: -I/usr/local/mysql/include  -g -Os -arch i386 -fno-common   -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL
-- MySQL Link flags: 
-- Configuring cppconn
-- Configuring drivermanager
-- Configuring test cases
-- Configuring examples
-- Configuring done
-- Generating done
-- Build files have been written to: $HOME/install/tests/mysql_connector_cpp_1_0_0_preview

$ make
[  3%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_connection.o
[  7%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_constructed_resultset.o
[ 10%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_driver.o
[ 14%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_exception.o
[ 17%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_metadata.o
[ 21%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_prepared_statement.o
[ 25%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_ps_resultset.o
[ 28%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_resultset.o
[ 32%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_resultset_metadata.o
[ 35%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_res_wrapper.o
[ 39%] Building CXX object cppconn/CMakeFiles/mysqlcppconn.dir/mysql_statement.o
Linking CXX shared library libmysqlcppconn.dylib
ld: library not found for -ldylib1.10.5.o
collect2: ld returned 1 exit status
make[2]: *** [cppconn/libmysqlcppconn.dylib] Error 1
make[1]: *** [cppconn/CMakeFiles/mysqlcppconn.dir/all] Error 2
make: *** [all] Error 2

$ sudo find /usr -name "*dylib1*"
/usr/lib/dylib1.10.5.o
/usr/lib/dylib1.o

How to repeat:
see above

Suggested fix:
none
[6 Aug 2008 17:45] Giuseppe Maxia
more information.
Using the svn tree, compilation succeeds.
[6 Aug 2008 18:11] Sveta Smirnova
Bug is not repeatable on Mac OSX 10.4
[6 Aug 2008 21:29] Sveta Smirnova
Thank you for the report.

I can not repeat describe behavior. Please indicate version of cmake you use.
[6 Aug 2008 21:52] Giuseppe Maxia
$ cmake --version
cmake version 2.6-patch 0

Notice that the failure happens only withe the preview package
http://downloads.mysql.com/forge/connector_cpp_preview/mysql_connector_cpp_1_0_0_preview.t...

Using the svn tree (revision 141) it builds as expected.

Notice that the failure happens on Mac OSX 10.5
[7 Aug 2008 16:44] Ulf Wendel
Giuseppe, 

can you run "make VERBOSE=1" and post the output of it?

Thanks!
Ulf
[7 Aug 2008 17:46] Giuseppe Maxia
as requested:

$ make VERBOSE=1
/opt/local/bin/cmake -H/Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview -B/Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview --check-build-system CMakeFiles/Makefile.cmake 0
/opt/local/bin/cmake -E cmake_progress_start /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview/CMakeFiles /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview/CMakeFiles/progress.make
make -f CMakeFiles/Makefile2 all
make -f cppconn/CMakeFiles/mysqlcppconn.dir/build.make cppconn/CMakeFiles/mysqlcppconn.dir/depend
cd /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview/cppconn /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview/cppconn /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview/cppconn/CMakeFiles/mysqlcppconn.dir/DependInfo.cmake --color=
make -f cppconn/CMakeFiles/mysqlcppconn.dir/build.make cppconn/CMakeFiles/mysqlcppconn.dir/build
Linking CXX shared library libmysqlcppconn.dylib
cd /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview/cppconn && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/mysqlcppconn.dir/link.txt --verbose=1
/opt/local/bin/c++   -isysroot /Developer/SDKs/MacOSX10.4u.sdk   -dynamiclib -headerpad_max_install_names -L/opt/local/lib/ -o libmysqlcppconn.dylib -install_name /Users/gmax/install/tests/mysql_connector_cpp_1_0_0_preview/cppconn/libmysqlcppconn.dylib CMakeFiles/mysqlcppconn.dir/mysql_connection.o CMakeFiles/mysqlcppconn.dir/mysql_constructed_resultset.o CMakeFiles/mysqlcppconn.dir/mysql_driver.o CMakeFiles/mysqlcppconn.dir/mysql_exception.o CMakeFiles/mysqlcppconn.dir/mysql_metadata.o CMakeFiles/mysqlcppconn.dir/mysql_prepared_statement.o CMakeFiles/mysqlcppconn.dir/mysql_ps_resultset.o CMakeFiles/mysqlcppconn.dir/mysql_resultset.o CMakeFiles/mysqlcppconn.dir/mysql_resultset_metadata.o CMakeFiles/mysqlcppconn.dir/mysql_res_wrapper.o CMakeFiles/mysqlcppconn.dir/mysql_statement.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc 
ld: library not found for -ldylib1.10.5.o
collect2: ld returned 1 exit status
make[2]: *** [cppconn/libmysqlcppconn.dylib] Error 1
make[1]: *** [cppconn/CMakeFiles/mysqlcppconn.dir/all] Error 2
make: *** [all] Error 2
[7 Aug 2008 22:20] Ulf Wendel
/opt/local/bin/c++   -isysroot /Developer/SDKs/MacOSX10.4u.sdk 

You are using a 10.4 SDK on 10.5? 

Please try compiling again with: export MACOSX_DEPLOYMENT_TARGET=10.4 or add -mmin-macosx-version=10.4 to your cflags.

Ulf
[7 Aug 2008 22:50] Giuseppe Maxia
Ulf,
I am using Mac OSX 10.5, and remember that compilation succeeds if I compile the source tree from subversion, but fails with the preview package.
[8 Aug 2008 6:39] Giuseppe Maxia
After much banging my head around, I found the reason. 
My first execution of cmake created a CmakeCache.txt file. That was created with a different version of MySQL installed on my box.
When I ran cmake again, it used the values stored in CmakeCache.txt instead of getting new ones.
Removing the cache file did the trick.
The bug, is there is one in this case, is that cmake fails to detect a change of environment between runs.
Case closed. The package compiles.
[8 Aug 2008 8:31] Ulf Wendel
Yes, cmake does cache its variables ("settings"). cmake -L gives you a list of available settings. cmake -D VARNAME=VALUE can be used to set different values, for example to configure a different path to the mysql_config tool. However, its hardly wrong to delete CMakeCache.txt before running cmake again.

Any clue why your system has choosen the 10.4 SDK ? Did it come from mysql_config (mysql_config --help -> include or lib) - the other MySQL you had installed? 

I'm asking because on Solaris, mysql_config is the usual suspect. On Solaris you might get Sun compiler / Sun Studio compliant setting settings which will make the compilation fail when using GCC (see README). Maybe we should add a similar hint to the README file as long as we are not sure if the CMakeLists.txt needs to be fixed or not.

Ulf