compiling GTK apps under cygwin



Jan-Steinke gmx de writes: 
I installed cygwin and GTK+ 2.2.1 and wanted to compile a little
example program:

When you say you installed GTK+ 2.2.1, what exactly do you mean? You
compiled and installed it from source? You used the prebuilt Win32
packages I provide? If the latter, you should know that those aren't
for use by Cygwin programs. Using them from Cygwin programs might
work, but if so, it's more by accident than on purpose.

For Cygwin programs, you need GTK+ etc built for Cygwin. See
http://web.sfc.keio.ac.jp/~s01397ms/cygwin/ . But hopefully those are
what you are using.

When I tried to compile it with 
"gcc 'pkg-config --cflags --libs gtk+-2.0' hello.c -o hello",

You should use the backquote character ` and not the single quote '
. The libraries should be last on the command line. Also, it is
customary to have the output file name relative early on the command
line. All in all, use something like:

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

(This has nothing to do with GTK per se, it's the normal behaviour of
Unix-like tools.)

I get some errors like:
/cygdrive/c/..../ccmGHn91.o(.text+0x4c):hello.c: undefined reference to 
'_gtk_init_abi_check'

If you look in gtkmain.h, you will notice that on G_PLATFORM_WIN32
(Win32 and Cygwin), a call to gtk_init() will in fact be compiled as a
call to gtk_init_abi_check(). Also, gtkmain.c, when compiled on
G_PLATFORM_WIN32, provides such a function. But your real problem
probably is that the GTK library isn't searched at all, because of the
wrong order on the gcc command line.

--tml





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]