The error is:
Undefined symbols for architecture x86_64:
"_mysql_init", referenced from:
_main in dao-8fe5b4.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
when I tried to compile the cpp file using the following command.
g++ -o test_install -I/usr/local/include -I/usr/local/include/cppconn -L/usr/local/lib dao.cc
The dao.cc file is:
#include <iostream>
#include <cstdio>
#include <mysql/mysql.h>
using namespace std;
int
main() {
MYSQL mysql;
mysql_init(&mysql);
return 0;
}
When I do not call mysql_init function, there is no error. So the "include" procedure is correct.
The header files are in /usr/local/inclulde and /usr/local/cppconn, and in /usr/local/lib, the lib files are:
libmysqlclient.18.dylib libmysqlcppconn-static.a
libmysqlclient.a libmysqlcppconn.7.1.1.6.dylib
libmysqlclient.dylib libmysqlcppconn.7.dylib
libmysqlclient_r.18.dylib libmysqlcppconn.dylib
libmysqlclient_r.a libmysqld.a
libmysqlclient_r.dylib libmysqlservices.a
But why it can not link to the functions?