Mysql C API undefined reference to `mysql_init’

Today I was trying to compile simple program written in C to connect mysql

http://www.ucl.ac.uk/is/mysql/c/
http://www.osix.net/modules/article/?id=517

/tmp/ccetdBsn.o: In function `main’:
sqltest.c:(.text+0x35): undefined reference to `mysql_init’
sqltest.c:(.text+0x77): undefined reference to `mysql_real_connect’
sqltest.c:(.text+0x86): undefined reference to `mysql_error’
sqltest.c:(.text+0xbf): undefined reference to `mysql_query’
sqltest.c:(.text+0xce): undefined reference to `mysql_error’
sqltest.c:(.text+0xfc): undefined reference to `mysql_use_result’
sqltest.c:(.text+0x130): undefined reference to `mysql_fetch_row’
sqltest.c:(.text+0x144): undefined reference to `mysql_free_result’
sqltest.c:(.text+0x14f): undefined reference to `mysql_close’

I found some people also face this problem.

The problem solved after giving

gcc -o test  -L/usr/lib/mysql -lmysqlclient test.c

src: http://lists.mysql.com/mysql/200178

Leave a Reply

Your email address will not be published.