开发者

calling sql from C++

开发者 https://www.devze.com 2023-04-10 13:25 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号