Mysql error - undefined reference to `mysql_real_connect' and others

194 Views Asked by At

I am trying to move a client app from an old box running openSUSE 13.2 (Harlequin) (i586) to a Raspberry pi running Raspbian GNU/Linux 11 (bullseye) (32-bit OS). The old box is running Ver 15.1 Distrib 10.0.27-MariaDB, for Linux (i686) using readline 5.2

The raspberry pi is running Ver 15.1 Distrib 10.5.15-MariaDB, for debian-linux-gnueabihf (armv8l) using EditLine wrapper

So I thought it would be easy!

Using the old command line (I changed lib64 to just lib):

gcc -o scan -L/usr/lib64 -lmysqlclient -lz -ldl -lm -lpthread -lssl -lcrypto -I/usr/include/mysql -I/usr/include/mysql/mariadb -std=c99  -g -Wfatal-errors scan.c

I get linker errors:

usr/bin/ld: /tmp/ccTqpyuX.o: in function `get_mappings':
/home/nigel/scan.c:218: undefined reference to `mysql_init'
/usr/bin/ld: /home/nigel/scan.c:218: undefined reference to `mysql_real_connect'
/usr/bin/ld: /home/nigel/scan.c:220: undefined reference to `mysql_select_db'
/usr/bin/ld: /home/nigel/scan.c:222: undefined reference to `mysql_close'
/usr/bin/ld: /home/nigel/scan.c:229: undefined reference to `mysql_close'
/usr/bin/ld: /home/nigel/scan.c:233: undefined reference to `mysql_query'
/usr/bin/ld: /home/nigel/scan.c:235: undefined reference to `mysql_store_result'
/usr/bin/ld: /home/nigel/scan.c:237: undefined reference to `mysql_num_rows'
/usr/bin/ld: /home/nigel/scan.c:240: undefined reference to `mysql_fetch_field'
/usr/bin/ld: /home/nigel/scan.c:244: undefined reference to `mysql_fetch_row'
/usr/bin/ld: /home/nigel/scan.c:268: undefined reference to `mysql_free_result'
/usr/bin/ld: /home/nigel/scan.c:271: undefined reference to `mysql_close'
/usr/bin/ld: /tmp/ccTqpyuX.o: in function `create_SQL':
/home/nigel/scan.c:506: undefined reference to `mysql_init'
/usr/bin/ld: /home/nigel/scan.c:506: undefined reference to `mysql_real_connect'
/usr/bin/ld: /home/nigel/scan.c:508: undefined reference to `mysql_select_db'
/usr/bin/ld: /home/nigel/scan.c:512: undefined reference to `mysql_close'
/usr/bin/ld: /home/nigel/scan.c:519: undefined reference to `mysql_error'
/usr/bin/ld: /home/nigel/scan.c:520: undefined reference to `mysql_close'
/usr/bin/ld: /home/nigel/scan.c:524: undefined reference to `mysql_query'
/usr/bin/ld: /home/nigel/scan.c:526: undefined reference to `mysql_store_result'
/usr/bin/ld: /home/nigel/scan.c:527: undefined reference to `mysql_free_result'
/usr/bin/ld: /home/nigel/scan.c:550: undefined reference to `mysql_query'
/usr/bin/ld: /home/nigel/scan.c:552: undefined reference to `mysql_store_result'
/usr/bin/ld: /home/nigel/scan.c:553: undefined reference to `mysql_free_result'
/usr/bin/ld: /home/nigel/scan.c:561: undefined reference to `mysql_close'
collect2: error: ld returned 1 exit status

I thought that mariadb should be a drop-in replacement for mysql, so I am wondering why the library labels are not recognised. I tried replacing lmysqlclient with lmariaddb-client with no difference.

The program scans I/O around the house and updates a database.

Any help greatly appreciated.

cheers, Nigel

I tried replacing lmysqlclient with lmariaddb-client with no difference.

0

There are 0 best solutions below