Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gtk can't find "<config.h>"

Tags:

c

gtk

I find many examples on various gtk uses on the net but most of them contains included header

#include <config.h>

and I can't fint this header nowhere so I can't get those examples to work.

What is this about?
Where I can take or with what I can replace this header?
Or I can configure such files/projects differently to get them work as other gtk project works on my comp?

Currently I try to compile socket example testsocket.c and during compilation I get error undefined reference to 'create_child_plug'. I don't see any reason for this to don't work except in this header.
But I may be wrong anyway.

like image 236
Wine Too Avatar asked Feb 24 '12 23:02

Wine Too


1 Answers

I think you're trying to compile a single source file on its own, that wasn't designed to work on its own. Two reasons.

The first reason: config.h is the default name of the header file output by Autoconf that contains platform-specific defines. That's why you won't find it anywhere - it's generated when you run ./configure on your project and its contents depend on how your system is configured. So it won't be included with any project, you have to generate it yourself by using Autoconf. Or just comment out the #include <config.h> and see what definitions are missing, then define them yourself.

The other reason:

Currently I try to compile socket example testsocket.c and during compilation I get error undefined reference to 'create_child_plug'. I don't see any reason for this to don't work except in this header. But I may be wrong anyway.

Actually, that file contains a definition of create_child_plug:

extern guint32 create_child_plug (guint32 xid, gboolean local);

So the problem isn't that create_child_plug isn't defined. You don't need a header, it's defined right there in the source file. extern means that the actual code for this function is in a different source file. In this case, you are getting a link-time (not compile-time) error because the linker can't find any code for that function. You should look for it in a .c file, not a .h file, and compile that code too.

I suggest you download the whole GTK source code and compile that, and run the test programs from there, instead of picking individual source files off the net.

like image 158
ptomato Avatar answered Nov 20 '22 00:11

ptomato