Compile line in Makefile does not work if client libs are static

Bug #324912 reported by Erik Ljungstrom
2
Affects Status Importance Assigned to Milestone
MySQL Data Dumper
Status tracked in Trunk
0.1
Fix Released
Medium
Domas Mituzas
Trunk
Fix Released
Medium
Domas Mituzas

Bug Description

If the libmysqlclient_r library is static, gcc will implicitly link against it statically. Therefore the default compile line as chosen by the `make` command using the current Makefile won't work:

$ make
cc `mysql_config --cflags` `pkg-config --cflags glib-2.0 gthread-2.0` -Wall -O3 -g -dynamic `mysql_config --libs_r` `pkg-config --libs glib-2.0 gthread-2.0` mydumper.c -o mydumper
/tmp/ccgUIPyb.o: In function `dump_table_data':
/home/erik/dev/0.1/mydumper.c:580: undefined reference to `mysql_query'
/home/erik/dev/0.1/mydumper.c:581: undefined reference to `mysql_error'
/home/erik/dev/0.1/mydumper.c:586: undefined reference to `mysql_use_result'
....

This however works:

c `mysql_config --cflags` `pkg-config --cflags glib-2.0 gthread-2.0` -Wall -O3 -g -dynamic `mysql_config --libs_r` `pkg-config --libs glib-2.0 gthread-2.0` mydumper.c -o mydumper -lmysqlclient_r

So suggested change to Makefile:

CFLAGS=`mysql_config --cflags` `pkg-config --cflags glib-2.0 gthread-2.0` -Wall -O3 -g
LDFLAGS=`mysql_config --libs_r` `pkg-config --libs glib-2.0 gthread-2.0`

all:
        cc -g $(CFLAGS) mydumper.c -o mydumper $(LDFLAGS)

clean:
        rm -rf mydumper dump *~ *BAK *.dSYM *.o

indent:
        gnuindent -ts4 -kr -l200 dump.c

which produces this line which works regardless of whether the lib is static or dynamic:

cc -g `mysql_config --cflags` `pkg-config --cflags glib-2.0 gthread-2.0` -Wall -O3 -g mydumper.c -o mydumper `mysql_config --libs_r` `pkg-config --libs glib-2.0 gthread-2.0`

Cheers,
Erik

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.