Re: compiling gtk-apps in win32



I have VC++ 2005 ee in my windows xp.

Hmm, what is "ee"? Express? Enterprise? And do you want to use just
the IDE, i.e. Visual Studio, or do you intend to use makefiles (and
Microsoft's Make, nmake.exe)?

How do I compile my gtk c code then.

I assume you also have the GTK+ developer files, i.e. the headers and
import libraries needed? (For instance, as included in the "bundle"
zip archive from http://www.gtk.org/download-windows.html .) I also
assume you don't have some kind of Unix shell environment installed,
for instance as provided by MSYS, but use Microsoft tools only?

Add the "bin" folder of where you "installed" (simply unpacked the zip
file, if you used that) GTK+ to your PATH.

Then you just need to tell your compiler where to look for header
files and what import libraries to link with. To easily find out
those, run the command:

    pkg-config --msvc-syntax --cflags gtk-+2.0

to find out the -I flags. It should print out something like:

-mms-bitfields -Ic:/somewhere/include/gtk-2.0
-Ic:/somewhere/lib/gtk-2.0/include -Ic:/somewhere/include/atk-1.0
-Ic:/somewhere/include/cairo -Ic:/somewhere/include/pango-1.0
-Ic:/somewhere/include/glib-2.0 -Ic:/somewhere/lib/glib-2.0/include

Copy that (except for the -mms-bitfields which is a gcc-specific flag
which unfortunately the pkg-config mechanism isn't clever enough to
drop when outputting flags in the Microsoft syntax) into the
appropriate dialog in Visual Studio (or into your makefile).

To find out the libraries, correspondingly run:

    pkg-config --msvc-syntax --libs gtk+-2.0

which should print out something like:

/libpath:c:/somewhere/lib gtk-win32-2.0.lib gdk-win32-2.0.lib
atk-1.0.lib gdk_pixbuf-2.0.lib pangowin32-1.0.lib gdi32.lib
pangocairo-1.0.lib pango-1.0.lib cairo.lib gobject-2.0.lib
gmodule-2.0.lib glib-2.0.lib intl.lib

Copy that again then into the appropriate dialog of Visual Studio (or
your makefile). (Actually, you can leave out the atk, gdk-pixbuf,
pango, gdi, cairo and intl libraries unless your code uses functions
from them.)

I treid it using VC++ 2005 ee  and compiles fine but the
output is that of a previously compiled file.

I don't understand what you mean here.

I cd into my project directory and run: gcc/g++ hello.c -o hello 'pkg-config -cflags --libs gtk-+2.0' but 
it says:
gcc'/'g++' not recognized as an internal or external command, operable program or batch.

That command uses several Unix specific details and won't work for
you. Also, when whatever documentation you found this example in says
"gcc/g++" it means "gcc" OR "g++" depending on whether the code is C
or C++...

--tml



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