Bug #22960 Linking fails when using --with-debug
Submitted: 3 Oct 2006 19:49 Modified: 3 Oct 2006 20:32
Reporter: Erik Wetterberg Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:mysql-5.1.11-beta OS:Linux (Fedora core 5)
Assigned to: Magnus Blåudd CPU Architecture:Any
Tags: debug, link, mysqlimport, safe_mutex

[3 Oct 2006 19:49] Erik Wetterberg
Description:
I configured to use debug mode:
./configure --with-debug --prefix=/usr/local/mysql
and ran make, which seems to complete most of the building, but fails in mysqlimport:

mysqlimport.o: In function `main':/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:587: undefined reference to `safe_mutex_init'
:/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:602: undefined reference to `safe_mutex_lock'
:/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:604: undefined reference to `safe_mutex_unlock'
:/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:613: undefined reference to `safe_mutex_lock'
:/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:615: undefined reference to `safe_mutex_unlock'
:/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:630: undefined reference to `safe_mutex_destroy'
mysqlimport.o: In function `worker_thread':/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:557: undefined reference to `safe_mutex_lock'
:/home/erik/mysql-5.1.11-beta/client/mysqlimport.c:559: undefined reference to `safe_mutex_unlock'

configure without debug and the make works.

How to repeat:
configure debug and run make on Fedora core 5
[3 Oct 2006 20:32] Magnus Blåudd
Just tested to build latest mysql-5.1 with the settings described. Could not repeat. 

Linking mysqlimport looks liked this:

if gcc -DUNDEF_THREADS_HACK -DDEFAULT_MYSQL_HOME="\"/usr/local/mysql\"" -DDATADIR="\"/usr/local/mysql/var\""  -I. -I. -I.. -I../include -I../include -I../regex     -g -O -DSAFE_MUTEX    -MT mysqlimport.o -MD -MP -MF ".deps/mysqlimport.Tpo" -c -o mysqlimport.o mysqlimport.c; \
then mv -f ".deps/mysqlimport.Tpo" ".deps/mysqlimport.Po"; else rm -f ".deps/mysqlimport.Tpo"; exit 1; fi
/bin/sh ../libtool --preserve-dup-deps --tag=CXX --mode=link g++  -g -O -DSAFE_MUTEX    -fno-implicit-templates -fno-exceptions -fno-rtti  -rdynamic  -o mysqlimport  mysqlimport.o   -lpthread ../libmysql_r/libmysqlclient_r.la ../mysys/libmysys.a  -lcrypt -lnsl -lm   -lz 
g++ -g -O -DSAFE_MUTEX -fno-implicit-templates -fno-exceptions -fno-rtti -rdynamic -o .libs/mysqlimport mysqlimport.o  -lpthread ../libmysql_r/.libs/libmysqlclient_r.so -lpthread -lpthread -lpthread -lpthread ../mysys/libmysys.a -lcrypt -lnsl -lm -lz -Wl,--rpath -Wl,/usr/local/mysql/lib/mysql
creating mysqlimport

Notice the "-DSAFE_MUTEX" define which includes 'safe_mutex_*' functions.

As you see ../mysys/libmysys.a is being linked with and there is where the 'safe_mutex_init' functions are.

Check with 
$> nm ../mysys/libmysys.a | grep safe_mutex_init

It they are not defined in libmysys, you need to do a "make clean" and make again.