Makefile Linking
Posted by: Matrix_UK jason
Date: August 30, 2005 03:53PM

Seems to be a common problem this, can anyone confirm that my linking is correct so I can look further into the C and H files. At the moment from what I am reading most of the errors when creating executable are linked to the libs.

Redhat 9 (Red Hat Linux 3.2.2-5)

gcc version 3.2.2 20030222

MySQL

--cflags
[-I'/usr/include/mysql']

--libs
[-L'/usr/lib/mysql' -lmysqlclient -lz -lcrypt - lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc - lnss_files -lnss_dns -lresolv]

--socket
[/var/lib/mysql/mysql.sock]

--port
[3306]

--version
[3.23.54]

ERROR
/src/db.c:3706: undefined reference to `mysql_ping'
db.o(.text+0x46d1):/src/db.c:3706: undefined reference to`mysql_error'
mysql.o(.text+0xc): In function `init_mysql':
/mysql.c:5: undefined reference to `mysql_init'
mysql.o(.text+0x37):/src/mysql.c:10: undefined reference to `mysql_real_connect'
mysql.o(.text+0x4b):/src/mysql.c:12: undefined reference to `mysql_close'
mysql.o(.text+0x7b): In function `close_db':
/src/mysql.c:22: undefined reference to `mysql_close'
mysql.o(.text+0x16d): In function `mysql_safe_query':
/src/mysql.c:57: undefined reference to `mysql_real_escape_string'
mysql.o(.text+0x219):/src/mysql.c:79: undefined reference to `mysql_real_query'
mysql.o(.text+0x35b): In function `do_pktrack':
/src/mysql.c:109: undefined reference to `mysql_store_result'
mysql.o(.text+0x381):src/mysql.c:116: undefined reference to `mysql_affected_rows'
mysql.o(.text+0x3e3):/src/mysql.c:127: undefined reference to `mysql_fetch_row'
mysql.o(.text+0x40e):/src/mysql.c:131:

ect, ect, for every MySQL command it finds, not linking with the librarys?, this is the Makefile.

CC = gcc
PROF = -O1 -ggdb
NOCRYPT =
C_FLAGS = -Wall $(PROF) $(NOCRYPT)
L_FLAGS = -Wall $(PROF) -L/usr/lib/mysql -lmysqlclient -lcrypt

O_FILES = act_comm.o act_ente.o act_info.o act_move.o act_obj.o act_wiz.o \
alias.o ban.o comm.o const.o db.o db2.o effects.o fight.o \
handler.o healer.o interp.o note.o lookup.o magic.o recycle.o \
save.o skills.o special.o tables.o update.o morecabal.o morefight.o \
extra.o moremagic.o titles.o necro.o olc.o olc_act.o \
graelik.o olc_save.o mem.o string.o bit.o commune.o tracerah.o \
iprog.o mprog.o rprog.o bounty.o mysql.o

pos2: $(O_FILES)

rm -f pos2
tar -cpf precompile_backup.tar.gz -z *.c *.h Makefile
mv precompile_backup.tar.gz ../backup
$(CC) -I/usr/include/mysql $(L_FLAGS) -o pos2 $(O_FILES)
mv pos2 ../area
cd ..

.c.o: merc.h
$(CC) -I/usr/include/mysql -c $(C_FLAGS) $

Contents of /usr/include/mysql

H
chardefs dbug errmsg history keymaps m_ctype
m_string my_congif my_glbal my_list my_net
my_no_pthread my_pthread my_sys mysql
mysql_com mysql_version mysqld_error
raid readline sslopt-case sslopt-longopota
aalopt-usage sslopt-vars title

C
mysql

Contents of /usr/libs/mysql

LIBS
libdbug.a libheap.a libmerge.a libmyisam.a
libmyisammrg.a libmysqlclient.a libmysqlclient.so.10
libmysqlclient.so.10.10.0 libmysqlclient_r.so.10
libmysqlclient_r.so.10.0.0 libmystrings.a
libmysys.a libnisam.a

Any Ideas?

Regards.
Jason

Options: ReplyQuote


Subject
Views
Written By
Posted
Makefile Linking
2233
August 30, 2005 03:53PM
506
August 31, 2005 12:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.