LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   C++, where does the preprocessor search for .h files? (https://www.linuxquestions.org/questions/linux-newbie-8/c-where-does-the-preprocessor-search-for-h-files-751575/)

mickwaffle 08-31-2009 02:40 PM

C++, where does the preprocessor search for .h files?
 
hello, i have finished installing mysql, howeve some of the files were missing, like mysql.h. anyway i have downloaded a DEV version which has all the files im looking for, however when i add my c++ file to the directory that they are in, it still does not run because it cannot find the mysql.h where does the compiler look for these files, or where should i put them?

mickwaffle 08-31-2009 04:24 PM

ok, just another thing, i have managed to install mysql fully along with all the libraries, now how do i compile a program, that has:
'#include <mysql.h>'
this says that it cant find mysql.h, so how do i tell the compiler where the libraries are?

djeikyb 08-31-2009 05:17 PM

The extent of my programming skill is ./configure; make; make install, but I'd guess your compiler manual tells you how to specify library paths. Failing that, the internet probably has a newbie guide for C++ that tells you how to specify a library path in the code.

When I extract a source package to compile it, I sometimes see a lib/ folder, and I'd guess the configure.sh script tells make that this is where important library files are, and make then runs the appropriate commands. If I were you, I'd download a souce package (or use your mysql package), and examine the configure.sh and make files, see if you can work it out. For that matter, examine the program source code too. Learn by example!

headrift 08-31-2009 05:26 PM

Put your cpp file anywhere you want, and call g++ with a -I/path/to/mysql/includes so that it looks like this:

Code:

g\+\+ file.cpp -I/usr/include/mysql -o file
That will tell g++ to look for includes in the given directory.


All times are GMT -5. The time now is 10:32 AM.