1

i just started with c++ programming. For my new work, i have to download, install and take use of an external library. It is called ICE. It was composed as a .tar file, so i decomposed it inside my home-directory "/home/foo/ice". Now, there is the directory: "/home/foo/ice/src", within all the .h headers, i need for the program. But can i tell the compiler, where he can find all these new headers? I mean only with #include, he obviously doesn't know.

What i need:

#include <image.h>

"image.h" is inside "/home/foo/ice/src"

Greetings

user1786193
  • 17
  • 1
  • 5
  • Libraries usually come with documentation which will tell you how to install it. (Usually something like `./configure && make && sudo make install`). – Daniel Frey Nov 02 '13 at 10:15
  • 1
    And compilers also usually come with documentation how to set a "include file search path". (Usually `-I`.) – Martin R Nov 02 '13 at 10:17
  • You need to say which compiler, but I'll take a stab in the dark that it is `g++` or `clang`. Then you use `-I /directory/path` to say where to find `#include`s, `-L /d/p` to find libraries, and `-l ice` to link `libice.a`. – BoBTFish Nov 02 '13 at 10:19

2 Answers2

2

If you have gcc compiler you can use -I option.

From the manual :

-I dir: Add the directory dir to the list of directories to be searched for header files.

So for you it should be something like this:

g++ myprog.cpp -I /home/foo/ice/src -o myprog

But it is better to install the library, you should have some readme.txt or INSTALL file about how to do this..

klm123
  • 12,105
  • 14
  • 57
  • 95
0

You asked about linking a library, but your description shows that you have problems with the include path, which klm123 answered already.

The library paths for linking is another option, usually -Llibpath It may help to check the options of you compiler, here for example the Directory Options of GCC

Wolf
  • 9,679
  • 7
  • 62
  • 108