Bug #51706 Cannot compile my C project whith latest MySQL Version
Submitted: 4 Mar 2010 1:12 Modified: 26 May 2010 6:44
Reporter: Hernando Gonzalez Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:MySQL 5.1.44 & 5.5.2 OS:Linux (RHEL 5.4 x64)
Assigned to: CPU Architecture:Any
Tags: MySQL 5.1.44 & 5.5.2

[4 Mar 2010 1:12] Hernando Gonzalez
Description:
Hello,

I'm testing upgrade from MySQL 5 to MySQL 5.1 and to MySQL 5.5.2. everything is fine, but my C project cant compile fine.

I need say that with MySQL 5, and MySQL 5.4.3 compile without any problem.

When i try compile i have this result:

../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::~DatabaseMysql()':
DatabaseMysql.cpp:(.text+0x385): undefined reference to `mysql_close'
DatabaseMysql.cpp:(.text+0x3a1): undefined reference to `mysql_server_end'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::~DatabaseMysql()':
DatabaseMysql.cpp:(.text+0x445): undefined reference to `mysql_close'
DatabaseMysql.cpp:(.text+0x461): undefined reference to `mysql_server_end'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::~DatabaseMysql()':
DatabaseMysql.cpp:(.text+0x515): undefined reference to `mysql_close'
DatabaseMysql.cpp:(.text+0x531): undefined reference to `mysql_server_end'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::_TransactionCmd(char const*)':
DatabaseMysql.cpp:(.text+0x584): undefined reference to `mysql_query'
DatabaseMysql.cpp:(.text+0x5b0): undefined reference to `mysql_error'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::DirectExecute(char const*)':
DatabaseMysql.cpp:(.text+0xba6): undefined reference to `mysql_query'
DatabaseMysql.cpp:(.text+0xbff): undefined reference to `mysql_error'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::_Query(char const*, st_mysql_res**, st_mysql_field**, unsigned long*, unsigned int*)':
DatabaseMysql.cpp:(.text+0xcb0): undefined reference to `mysql_query'
DatabaseMysql.cpp:(.text+0xcd7): undefined reference to `mysql_error'
DatabaseMysql.cpp:(.text+0xd3b): undefined reference to `mysql_store_result'
DatabaseMysql.cpp:(.text+0xd4a): undefined reference to `mysql_affected_rows'
DatabaseMysql.cpp:(.text+0xd5e): undefined reference to `mysql_field_count'
DatabaseMysql.cpp:(.text+0xd87): undefined reference to `mysql_fetch_fields'
DatabaseMysql.cpp:(.text+0xda8): undefined reference to `mysql_free_result'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::DatabaseMysql()':
DatabaseMysql.cpp:(.text+0xef2): undefined reference to `mysql_server_init'
DatabaseMysql.cpp:(.text+0xef7): undefined reference to `mysql_thread_safe'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::DatabaseMysql()':
DatabaseMysql.cpp:(.text+0xfb2): undefined reference to `mysql_server_init'
DatabaseMysql.cpp:(.text+0xfb7): undefined reference to `mysql_thread_safe'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::Initialize(char const*)':
DatabaseMysql.cpp:(.text+0x14a7): undefined reference to `mysql_init'
DatabaseMysql.cpp:(.text+0x1584): undefined reference to `mysql_options'
DatabaseMysql.cpp:(.text+0x15be): undefined reference to `mysql_options'
DatabaseMysql.cpp:(.text+0x1603): undefined reference to `mysql_real_connect'
DatabaseMysql.cpp:(.text+0x1635): undefined reference to `mysql_get_client_info'
DatabaseMysql.cpp:(.text+0x165c): undefined reference to `mysql_get_server_info'
DatabaseMysql.cpp:(.text+0x1688): undefined reference to `mysql_autocommit'
DatabaseMysql.cpp:(.text+0x1843): undefined reference to `mysql_error'
DatabaseMysql.cpp:(.text+0x186d): undefined reference to `mysql_close'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::escape_string(char*, char const*, unsigned long)':
DatabaseMysql.cpp:(.text+0x134): undefined reference to `mysql_real_escape_string'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::ThreadEnd()':
DatabaseMysql.cpp:(.text+0x141): undefined reference to `mysql_thread_end'
../shared/Database/libmangosdatabase.a(DatabaseMysql.o): In function `DatabaseMysql::ThreadStart()':
DatabaseMysql.cpp:(.text+0x151): undefined reference to `mysql_thread_init'
../shared/Database/libmangosdatabase.a(QueryResultMysql.o): In function `QueryResultMysql::EndQuery()':
QueryResultMysql.cpp:(.text+0xd3): undefined reference to `mysql_free_result'
../shared/Database/libmangosdatabase.a(QueryResultMysql.o): In function `QueryResultMysql::~QueryResultMysql()':
QueryResultMysql.cpp:(.text+0x507): undefined reference to `mysql_free_result'
../shared/Database/libmangosdatabase.a(QueryResultMysql.o): In function `QueryResultMysql::NextRow()':
QueryResultMysql.cpp:(.text+0x551): undefined reference to `mysql_fetch_row'
QueryResultMysql.cpp:(.text+0x5e0): undefined reference to `mysql_free_result'
../shared/Database/libmangosdatabase.a(QueryResultMysql.o): In function `QueryResultMysql::~QueryResultMysql()':
QueryResultMysql.cpp:(.text+0x657): undefined reference to `mysql_free_result'
../shared/Database/libmangosdatabase.a(QueryResultMysql.o): In function `QueryResultMysql::~QueryResultMysql()':
QueryResultMysql.cpp:(.text+0x6e7): undefined reference to `mysql_free_result'
../shared/Database/libmangosdatabase.a(SqlDelayThread.o): In function `SqlDelayThread::run()':
SqlDelayThread.cpp:(.text+0x16d): undefined reference to `mysql_thread_init'
SqlDelayThread.cpp:(.text+0x20a): undefined reference to `mysql_thread_end'

How to repeat:
When i have this data( I can compile ) 

        libmysqlclient_r.so.15 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient_r.so.15
        libmysqlclient_r.so.15 (libc6) => /usr/lib/mysql/libmysqlclient_r.so.15
        libmysqlclient.so.15 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.15
        libmysqlclient.so.15 (libc6) => /usr/lib/mysql/libmysqlclient.so.15

When i have this data( I can't compile ) 

        libmysqlclient_r.so.16 (libc6,x86-64) => /usr/lib64/libmysqlclient_r.so.16
        libmysqlclient_r.so (libc6,x86-64) => /usr/lib64/libmysqlclient_r.so
        libmysqlclient.so.16 (libc6,x86-64) => /usr/lib64/libmysqlclient.so.16
        libmysqlclient.so (libc6,x86-64) => /usr/lib64/libmysqlclient.so
[4 Mar 2010 4:26] Valeriy Kravchuk
Thank you for the problem report. Please, send gcc command line used to compile. 

Had you installed from RPMs (then send the results of rpm -q -a | grep -i mysql) or from .tar.gz package?
[4 Mar 2010 4:44] Hernando Gonzalez
rpm -q -a | grep -i mysql
MySQL-server-community-5.5.2_m2-1.rhel5
MySQL-devel-community-5.5.2_m2-1.rhel5
MySQL-client-community-5.5.2_m2-1.rhel5
MySQL-community-debuginfo-5.5.2_m2-1.rhel5
MySQL-shared-community-5.5.2_m2-1.rhel5
MySQL-test-community-5.5.2_m2-1.rhel5

My C project is compile in this way:

autoreconf --install --force
automake --add-missing
mkdir objdir
cd objdir

export CXXFLAGS="-O3"
export CFLAGS="-O3"

../configure 

make
make install

(I need really clarify that with MySQL 5, and MySQL 5.4.3 i can compile without any problem)
[4 Mar 2010 4:59] Valeriy Kravchuk
When make runs it executes gcc commands for each .cpp file. So, please, either upload Makefile generated or just last gcc command line that produced errors.
[4 Mar 2010 5:32] Hernando Gonzalez
* This is the makefile.am where the compiler produce the error: http://paste2.org/p/700252
and this is the makefile.in generate for the compilation: http://paste2.org/p/700254

* This is the mysql part from configure.ac:

# here mysql
AC_MSG_CHECKING(whether to build/link MYSQL)
if test "x$DO_MYSQL" = "xyes"; then
AC_MSG_RESULT($DO_MYSQL)
AC_PATH_PROGS(MYSQL_CONFIG, mysql_config, mysql_config, $PATH)
    if test -x "$MYSQL_CONFIG"
        then
    # MySQL v4 uses --include while v3 uses --cflags
        MYSQL_INCLUDES="`$MYSQL_CONFIG --include`" || \
	    MYSQL_INCLUDES="`$MYSQL_CONFIG --cflags`"
        MYSQL_LIBS="`$MYSQL_CONFIG --libs_r`"
	CXXFLAGS="-DDO_MYSQL $CXXFLAGS"
	# Workaround for --as-needed linker flag that comes sometimes from mysql
	if echo $MYSQL_LIBS|grep "\-Wl,--as-needed" > /dev/null; then
		MYSQL_LIBS=`echo $MYSQL_LIBS|sed -e "s/-Wl,--as-needed//"`;
		AC_MSG_WARN([Your mysql libs contains -Wl,--as-needed, this is not good, problem fixed in more recent mysql versions])
	fi
    fi
else
AC_MSG_RESULT($DO_MYSQL)
fi

* This is all configure.ac http://paste2.org/p/700246
[26 Apr 2010 6:44] Sveta Smirnova
Thank you for the feedback.

All links expired now. Please send us last gcc command line that produced errors.
[26 May 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".