views:

3804

answers:

2

I'm trying to add an header file to dev-C++ but when I compile it it doesn't work. Here are my exact steps (for my example, I'm trying to get mysql.h to work):

  1. copy "mysql.h" into c:\dev-c++\includes
  2. check that in dev-C++ tools > compiler options > directories > c includes and c++ includes have the path to "c:\dev-c++\includes"
  3. include #include at the top of my file
  4. compiled

This is what the dev-C++ compiler told me:

13 C:\Documents and Settings\Steve\Desktop\server code\setup1\main.c `mysql' undeclared (first use in this function)

As well as other errors due to not locating the header file

Are the steps I've outlined correct? Or is there something else I need to do to get the header files to compile.

P.S. I tried doing the same with VS2008 (put mysql.h in the vs2008 include folder, etc) but still have the same error. I would like to stick with Dev-c++ if possible.

+2  A: 

You didn't say how you included it at the top of your file. This should work if you did

#include "mysql.h"

rather than

#include <mysql>

which is a mistake that people sometimes make.

EDIT: Perhaps try using relative paths rather than an absolute path (as you seem to be doing) when specifying additional include directories? I don't know if that would make a difference (and I don't have the time to check) but I've always used relative paths and it's always worked for me (it's also good practice anyway). So, instead of

C:\Projects\ProjectName\Include

something like

\Include or ..\Include depending on your project file structure.

jpoh
#include "mysql.h"
Steve
A: 

Dev-C++ is a port of GCC, so try this page: http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html.

Note that you probably have to tinkle with the Makefile.

Seiti