calling sql from C++
my c++ program has sql code in it, and it runs f开发者_开发技巧ine on one linux machine but on the other, I get the following error when I compile it
g++ test.cpp -o a -L/usr/lib/mysql -lmysqlclient -lboost_date_time
fatal error: /usr/include/mysql/mysql.h: No such file or directory
compilation terminated.
I have mysql installed but I am obviously missing some step somewhere (on this machine with a new ubuntu installation)
can someone please let me know the fix. thx!
Looks like your computer doesn't have MySQL installed (in which case, install it), or is installed to a location other than /usr/include/mysql/mysql.h
(in which case, change your compile command to point at the correct location)
You need to pass the location of mysql
include files.
You are passing library location with:
-L/usr/lib/mysql -lmysqlclient
.
If you know where mysql headers are you need to pass them to compiler using:
-I/path/to/directory/with/mysql/headers
精彩评论