Re: Compiling gtk apps on MingW



Ricardo Malafaia wrote:

well, my Makefile is like this now

PREFIX=/mingw
PATH=/d/GtkWin/bin:/usr/bin:/bin:/mingw/bin
CPPFLAGS=-O2 -I/d/GtkWin/include
PKG_CONFIG_PATH=/d/GtkWin/lib/pkgconfig
LD_LIBRARY_PATH=/d/GtkWin/bin:/d/GtkWin/lib:/lib:/usr/lib:/mingw/lib

GTK_CFLAGS=`pkg-config --cflags gtk+-2.0 | sed -e 's/d:/\/d/'`
GTK_LIBS=`pkg-config --libs gtk+-2.0 | sed -e 's/d:/\/d/'`

LDFLAGS=-L/d/GtkWin/bin -L/d/GtkWin/lib 

all: exec/teste.exe

exec/teste.exe: teste.c
      gcc.exe -mwindows -mms-bitfields $(GTK_CFLAGS) $(GTK_LIBS)
      teste.c -o exec/teste.exe

And still doesn't work.  The gcc command line shown, shows not the
result of the sed processed pkg-config output, but simply `pkg-config
--cflags gtk+-2.0 | sed -e 's/d:/\/d/'`.

Makefiles are not supposed to contain (or evaluate, rather)
"`"-expressions. 'make' doesn't treat them the same way the shell does,
i.e. expanding them. 'make' provides the "shell" function for shell
command expansion instead. Study the 'make' documentation for further
information about this. However, if you use autotools on MinGW (like I
do and like it is recommended), you don't need that either.

If you insist on entering it manually then the GTK+-relevant part of
the linker parameters to include libs should look similar to this:

-L<path_to_your_gtk_installation>/gtk-2.0/lib -lgtk-win32-2.0 \
-lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 \
-lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0

When using autotools, this is what pkg-config adds to the <app>_LDADD
variable automatically (provided GTK+ is installed properly). In
configure.in the following two lines add that library stuff the portable
way, i.e. without need to change anything between MinGW and Unix.

pkg_modules="gtk+-2.0 >= 2.0.0"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])

In makefile.am (in your package src/ directory) there should be the line

<app>_LDADD = @PACKAGE_LIBS@

where <app> is the name of the target binary, usually your package name.
You may also add other required libs there, either directly by name or
by other variable names.

This way, when you got that whole automake + autoconf stuff set up, a
simple 'configure' run (which may take quite some time on MinGW, though)
creates (long but often functional) "Makefile"s. Note that both the bin/
and the lib/ directory of GTK+ should be added to your shell's $PATH
before running 'configure'. Otherwise 'configure' will abort,
complaining it can't find either pkg-config or the GTK+ libs.



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