i am trying to call a octave function from C code but the problem is that when why run this command in octave mkoctfile --mex addition_GUI.c
error occurs addition_GUI.c:1:20: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
#include<gtk/gtk.h>
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
mxArray *in[2], *out[1];
in[0] = mxCreateDoubleScalar(1);
in[1] = mxCreateDoubleScalar(2);
mexCallMATLAB(1, out, 2, in, "addition");
mexCallMATLAB(0, NULL, 1, out, "disp");
mxDestroyArray(in[0]);
mxDestroyArray(in[1]);
mxDestroyArray(out[0]);
}
void static call(GtkWidget *widget,gpointer data)
{
g_print("\n%s\n",gtk_entry_get_text(GTK_ENTRY(data)));
gint a=3;
gint b=2;
gint x;
x=a+b;
char y[4];
sprintf(y, "%d", x);
gtk_entry_set_text(GTK_ENTRY(data),y);
}
int main(int agrc, char *agrv[])
{
gtk_init(&agrc,&agrv);
GtkWidget *entry,*window,*button,*hbox;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window,"delete-event",G_CALLBACK(gtk_main_quit),NULL);
hbox=gtk_hbox_new(0,0);
gtk_container_add(GTK_CONTAINER(window),hbox);
button=gtk_button_new_with_mnemonic("ADD");
entry=gtk_entry_new();
const char* sum="3+2";
gtk_entry_set_text(GTK_ENTRY(entry),sum);
g_signal_connect(button,"clicked",G_CALLBACK(call),entry);
g_signal_connect(entry,"activate",G_CALLBACK(call),entry);
gtk_box_pack_start(GTK_BOX(hbox),button,0,0,0);
gtk_box_pack_start(GTK_BOX(hbox),entry,0,0,0);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
Have you tried adding the necessary gtk+ header search path(s) on the
mkoctfile
command line?You should be able to use the
pkg-config
utility to include all the header directories automatically e.g.Alternatively, you could run
on the command line and manually copy the include paths that it outputs to your mkoctfile command. You will need both the
pkg-config
package and the development files and headers for gtk+-2.0 i.e. thelibgtk2.0-dev
package installed on your system.In order to create a runable mex executable you will probably need to add the corresponding libraries using the mkoctfile
-L
option - or by adding--libs
to thepkg-config
command i.e.or (to add libraries manually)