views:

252

answers:

3

Hi, i have written a program under ubuntu, in which i include gtkmozembed.h. I am facing a problem in compiling the program.Below is the simplest form of a program which uses gtkmozembed.

#include <gtk/gtk.h>
#include <stdio.h>
#include <gtkmozembed.h>

int main(){
        GtkWidget *mozEmbed;
        mozEmbed = gtk_moz_embed_new();
        return 0;
}

Eventhough, the above program is doing nothing, compiling that program is a lot for me... I am trying to comile the above program like below

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

and it is giving the following error...

error: gtkmozembed.h: No such file or directory

I can understand, something else has to be added to the above gcc line,so that the compiler can find the gtkmozembed.h, but not getting what is that, 'something'...Looking for someone's help..Thank you...

+1  A: 

Your problem is that gtkmozembed.h is not found in the standard include file lookup path (well, the error does tell you that pretty obviously). On my system it lives in $(include)/gtkmozembed/, so you have two options

  1. Change the path of the included file in your source

    #include <gtkmozembed/gtkmozembed.h>
    
  2. or manually add the path to the lookup path

    gcc `pkg-config --libs --cflags gtk+-2.0` -I/usr/include/gtkmozembed test.c -o test
    

You should go with option 1).

This will tell gcc where to find the include file, but as pointed out by Matthew this is not enough: you will most probably also need to add more information for linking and required additional includes. Thankfully gtk-mozembed comes with a pkg-config file, so you can get all the needed information like you did for gtk+-2.0 with

pkg-config --libs --cflags mozilla-gtkmozembed-embedding

or combined with the other call

gcc `pkg-config --libs --cflags gtk+-2.0 mozilla-gtkmozembed-embedding` test.c -o test

You should also (just for kicks) have a look at what pkg-config does. The part in "`" is just what is return by the shell when executing that command. On my machine:

$ pkg-config --libs --cflags mozilla-gtkmozembed-embedding
-DXPCOM_GLUE -fshort-wchar \
-I/usr/include/xulrunner-1.9.2  -L/usr/lib/xulrunner-devel-1.9.2/lib -lxpcomglue 

(line breaks added by me). The -I parts just adds additional needed directories to the include file lookup path -- they were emitted because you called with --cflags. The entries with -lxpcomglue is due to calling with --libs and ask for linking against this library, i.e. libxpcomglue.so. It is located in /usr/lib/xulrunner-devel-1.9.2/lib. The rest are a define and a gcc flag needed for gtkmozembed.

honk
i think i have not installed gtkmozembed. When i run with"gcc `pkg-config --libs --cflags gtk+-2.0 mozilla-gtkmozembed-embedding` test.c -o test"it is giving error like this.Package mozilla-gtkmozembed-embedding was not found in the pkg-config search path.How to install that package? thank you...
ganapati
A: 

Try this:

gcc `pkg-config --libs --cflags gtk+-2.0 mozilla-gtkmozembed-embedding` test.c -o test
Matthew Talbert
i think i have not installed gtkmozembed. When i run with "gcc pkg-config --libs --cflags gtk+-2.0 mozilla-gtkmozembed-embedding test.c -o test" it is giving error like this. Package mozilla-gtkmozembed-embedding was not found in the pkg-config search path. How to install that package? thank you...
ganapati
You probably need to install libxul-dev.
Matthew Talbert
+1  A: 

Install libxul-dev (sudo apt-get install libxul-dev) and include

#include <gtkmozembed.h>

in the main file(test.c) and compile with

gcc `pkg-config --cflags --libs gtk+-2.0 xulrunner-gtkmozembed`  test.c -o test
Gpathy