22

I am trying to compile the simple C example from this Tutorial on Ubuntu using gcc. What do I have to use as argument for gcc to include the needed libraries for #include <libappindicator/app-indicator.h>?

Drew Noakes
  • 284,599
  • 158
  • 653
  • 723
multiholle
  • 2,830
  • 8
  • 37
  • 58

6 Answers6

86
-I<search path to include files>
-L<search path to the lib file>
-l<libname>
Community
  • 1
  • 1
Kristofer
  • 3,061
  • 21
  • 28
16

Use the -l command line option. You can specify the library search path with the -L option. E.g:

gcc -o myprogram -lfoo -L/home/me/foo/lib myprogram.c

This will link myprogram with the static library libfoo.a in the folder /home/me/foo/lib.

Vijay Mathew
  • 26,037
  • 4
  • 58
  • 92
6
gcc example.c -o example  `pkg-config --cflags --libs appindicator-0.1`

pkg-config will fetch the required include and lib flags for libappindicator and it's dependencies. This assumes libappindictaor-dev package is already installed.

lijo
  • 301
  • 3
  • 5
6

What I do is:

pkg-config --list-all | grep indicator
hytromo
  • 1,381
  • 2
  • 25
  • 54
5

If you used apt-get, Synaptic Package Manager, etc. to get the appindicator library (vs. building it from source), did you only install the libappindicator1 package or did you also install libappindicator-dev to get the libappindicator header files? Linux packages very often have split the runtime libraries from the compile-time headers. That way people who only need the libraries to satisfy a dynamic link don't have to install unneeded headers. But since you're doing development you need those headers and therefore need the libappindicator-dev package as well.

mah
  • 38,251
  • 9
  • 74
  • 91
QuantumMechanic
  • 13,537
  • 3
  • 41
  • 66
  • I added the libappindictaor-dev package. What do I have to use with gcc as -l argument? – multiholle May 16 '11 at 11:52
  • 1
    According to http://packages.ubuntu.com/hu/natty/i386/libappindicator-dev/filelist you need to use `-I/usr/include/libappindicator-0.1/libappindicator` – QuantumMechanic May 16 '11 at 12:39
1

What you are trying to do here is making a gtk app, the above solutions are as applicable anywhere like using the -l option and -I option,

However for GTK apps you may also use pkg-config which make it easier as your paths can be predefined

http://www.freedesktop.org/wiki/Software/pkg-config

An interesting example can be found here http://developer.gnome.org/gtk/2.24/gtk-compiling.html

manugupt1
  • 2,199
  • 5
  • 26
  • 37