itcplpl
itcplpl

Reputation: 780

calling sql from C++

my c++ program has sql code in it, and it runs fine 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!

Upvotes: 1

Views: 138

Answers (2)

stefanB
stefanB

Reputation: 79780

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

Upvotes: 1

Ayjay
Ayjay

Reputation: 3433

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)

Upvotes: 1

Related Questions