PDA

View Full Version : C++: #include doesn't find file?



Guest1234
August 29th, 2005, 08:27 PM
I have installed via the Synaptic Package Manager the ligbdome2-0 package,
it's a package for manipulating xml/html files using DOM.
I have a class called XMLSerializable, which does include to the following file:

#include <gdome.h>

but when I try to compile Person.cpp that uses this class I get this error message:

XMLSerializable.h:4:19: gdome.h: No such file or directory

I have added to $PATH:
/usr/lib

where the files: /usr/lib/libgdome.so.0 and /usr/lib/libgdome.so.0.8.1 are located,
but it didn't help.

I've also added to $PATH /usr/include/libgdome where the file gdome.h is located,
but id didn't help either.

How can I make #include to look for gdome.h in the right place?

varunus
August 29th, 2005, 08:35 PM
You need to use package-config to compile libraries you install from synaptic.

An example:

gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`

Most likely, this library you installed had a ".pc" file included with it (you can check synaptic in the "installed files" section); simply replace "gtk+-2.0" in the above with the name of the .pc file (no extension there, though).

Most likely, you'll need to type the following (if the filename is libgdome-2.0.pc):

gcc filename.c `pkg-config --cflags --libs libgdome-2.0`

Or something like that.

thumper
August 29th, 2005, 08:43 PM
I have installed via the Synaptic Package Manager the ligbdome2-0 package,
it's a package for manipulating xml/html files using DOM.
I have a class called XMLSerializable, which does include to the following file:

#include <gdome.h>

but when I try to compile Person.cpp that uses this class I get this error message:

XMLSerializable.h:4:19: gdome.h: No such file or directory

I have added to $PATH:
/usr/lib

where the files: /usr/lib/libgdome.so.0 and /usr/lib/libgdome.so.0.8.1 are located,
but it didn't help.

I've also added to $PATH /usr/include/libgdome where the file gdome.h is located, but id didn't help either.

PATH is used to find executables not header files. What you are looking for is the -I or -isystem directive for gcc/g++


How can I make #include to look for gdome.h in the right place?
You might want to try something like this

g++ -isystem /usr/include/libgdome test.cpp -o test
Also LD_LIBRARY_PATH is used to find the shared object libraries, but /usr/lib is normally checked by default (at least I think it is).

mo_x
August 29th, 2005, 08:50 PM
Maybe you can change the line to:
#include <libgdome/gdome.h>

thumper
August 29th, 2005, 08:54 PM
Maybe you can change the line to:
#include <libgdome/gdome.h>
Yeah, I thought of that too, but then you have problems is gdome.h includes any other header files that it expects to be in the same directory (as often happens).

If gdome.h looks anything like this:

#ifndef GDOME_H_INCL_GUARD_THINGY
#define GDOME_H_INCL_GUARD_THINGY

#include <gdome_impl.h>
#include <gdome_other.h>

// lots of other stuff

#endif
Then if the directory that gdome.h lives in is not in the include path, then the compilation will stop by not finding the others.

That said, if it is a stand alone header file (ie doesn't include anything else), then this suggestion is the easiest and simplest solution.

mo_x
August 30th, 2005, 08:43 PM
You can also add the directory to the gcc search path for inlcude files, I think it's the -I option. It would be something like:
gcc -I/usr/include/libgdome

Kimm
August 30th, 2005, 08:45 PM
Probably a stupid question... but you do have the developement files installed I presume?