Next: , Previous: , Up: Top   [Contents]


4 Programming with the library

LibHideIP comes with a development package. You can use the following public functions and constants:

If you’re using C or C++ (or any language that can parse C header files), you can use the header file directly. Simply type:

	#include <libhideip.h>

and compile the program with the library, e.g.:

gcc -o your_prog your_prog.c -lhideip -ldl

If needed, LibHideIP should be first in link order.

If you want to use LibHideIP with some other programming language, you can generate bindings to LibHideIP for that language. You can use SWIG for this purpose. The header file is compatible with SWIG, so you can simply run:

swig -<your_lang> [<other options>] /path/to/libhideip.h

e.g.

swig -php -o lhip_wrap_php.c /usr/include/libhideip.h

You can then compile the generated wrapper files:

gcc -fpic -c lhip_wrap_*.c

and link them into one or separate shared libraries:

gcc -shared lhip_wrap_*.o -lhideip -o lhip_wrapper.so

After this, you can link your program with the wrapper library and LibHideIP:

gcc -o your_prog your_prog.c lhip_wrapper.so -lhideip -ldl

or use the library in other languages, as shown in the SWIG examples.

LibHideIP will not contain the interfaces compiled-in, because there may be incompatibilities between languages or even between different versions of the same language, causing compile-time or other conflicts and unnecessary dependencies.

By using SWIG yourself, you can be sure that such problems will not occur.


Next: , Previous: , Up: Top   [Contents]