2

I have a problem compiling a program written in C which should interact with a MySql db.

I'm using Ubuntu 11.04.

I type this:

gcc -o magazzino main_magazzino.c -L/usr/lib/mysql -lmysqlclient

and I get this error:

main_magazzino.c:4:25: fatal error: mysql/mysql.h: No such file or directory
compilation terminated.

2 Answers 2

2

-L and -l are only relevant in the linking phase, and the program already fails to compile.

Check that /usr/include/mysql/mysql.h exists. If you have installed the header files somewhere else (say /opt/mysql/include), add that location with -I/opt/mysql/include.

Sign up to request clarification or add additional context in comments.

2 Comments

In the directory include I mean /usr/include there's no file called mysql.h. There are many files .h .Also in the include directory there's no mysql directory ...
@Margherita That means you haven't installed the MySQL libraries at all. Install the linked MySQL C connector (on debian/Ubuntu systems: apt-get install libmysqlclient-dev).
0

you need to install mysql c connector. you can download from http://dev.mysql.com/downloads/connector/c/ after downloading you can specify header include path using -I option.

2 Comments

I have just downloaded the file you suggested : mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit.tar.gz . Now how do I install it? thanks
just extract it . you will find include folder inside extracted folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.