GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compile under Windows

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> General GTK+ Discussion
Author Message
GTKNoob2008
Familiar Face


Joined: 09 Jul 2008
Posts: 6

PostPosted: Wed Jul 09, 2008 7:58 am    Post subject: Compile under Windows Reply with quote

Hello,

i'm new at GTK programming.
I wanted to compile a simple Programm under Windows XP.

i have installed MSYS and MinGW. And added to the PATH:

    C:\GTK;
    C:\GTK\bin;
    C:\GTK\lib;
    C:\GTK\include\gtk-2.0\gtk;
    C:\GTK\include\gtk-2.0;
    C:\GTK\include\bin;
    C:\GTK\include\cairo
    C:\GTK\include\libglade-2.0
    C:\GTK\include\gtk-2.0
    C:\GTK\include\glib-2.0
    C:\GTK\lib\glib-2.0\include
    C:\GTK\lib\gtk-2.0\include
    C:\GTK\include\pango-1.0
    C:\GTK\include\atk-1.0
    C:\GTK\include\libxml2
    C:\GTK\include


When i started to compile it with:
Quote:
gcc hello.c -o hello.exe
...i got some errors. i think the compiler did not find the gtk header and libs ...

The first error is :

gtk/gtk.h No such file or directory.
..
..
..
hope someone can help me
greets GTKNoob
Back to top
Vadi
GTK+ Geek


Joined: 28 May 2008
Posts: 68

PostPosted: Wed Jul 09, 2008 12:29 pm    Post subject: Reply with quote

You need to add

Code: (C)
1
`pkg-config --cflags --libs gtk+-2.0`


To the compile line. Give that a try.
Back to top
GTKNoob2008
Familiar Face


Joined: 09 Jul 2008
Posts: 6

PostPosted: Wed Jul 09, 2008 1:51 pm    Post subject: Reply with quote

hi Vadi,

thank you for your help !!!
i tried your advice and added it to the comand line, but i get other errors...

gcc: `pkg-config: No such file or directory
gcc: gtk+-2.0: No such file or directory
cc1: Fehler: nicht erkannte Kommandozeilenoption >>-fcflags<<
cc1: Fehler: nicht erkannte Kommandozeilenoption >>-flibs<<

... he did not recognize this comand line options ...
do you have any idea ...
Back to top
caracal
GTK+ Geek


Joined: 21 Jun 2007
Posts: 91
Location: Wilkes Barre Pa

PostPosted: Wed Jul 09, 2008 2:47 pm    Post subject: Reply with quote

Umm do you have pkg-config installed?
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Wed Jul 09, 2008 3:08 pm    Post subject: Reply with quote

on windows, you can't do
Code: (Plaintext)
1
`pkg-config etc.`

unless you're using cygwin or msys because the windows shell (cmd) doesn't support backtick syntax.
also, all you need to add to %PATH% is C:\GTK\bin.

what I do (since msys doesn't work on vista x64) is to type
Code: (Plaintext)
1
2
pkg-config --cflags gtk+-2.0 > cflags.txt
pkg-config --libs gtk+-2.0 > ldflags.txt

then copy the contents of cflags.txt into a new environment variable called GTK_CFLAGS
and copy the contents of ldflags.txt into a new environment variabl called GTK_LDFLAGS,
then I make a new var called GTK_COMPILE which has this in it:
Code: (Plaintext)
1
%GTK_CFLAGS% %GTK_LDFLAGS%

then when I want to compile a gtk program, I can type:
Code: (Plaintext)
1
gcc file.c -o file %GTK_COMPILE%
Back to top
GTKNoob2008
Familiar Face


Joined: 09 Jul 2008
Posts: 6

PostPosted: Thu Jul 10, 2008 6:52 am    Post subject: Reply with quote

@caracal: no i haven't :? How can i install it ?

@dreblen: when i write the first comand line
Quote:
pkg-config --cflags gtk+-2.0 > cflags.txt

the output is:

Quote:
Package gdk-win32-2.0 was not found at the pkg-config search path.
Perhaps you should add the directory containing `gdk-wind32-2.0.pc´ to the PKG_CONFIG_PATH enviroment variable
Package ´gdk-win32-2.0´ required by ´GTK+´, not found


i have installed GTK+ with "win32-installer" from sourceforge, arn't there all Packages inside ?
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Thu Jul 10, 2008 2:54 pm    Post subject: Reply with quote

by that output, it would seem that you do have pkg-config installed, and it's telling you it can't find the proper files,
so you need to make a new environment variable called PKG_CONFIG_PATH and set it to
Code: (Plaintext)
1
C:\GTK\lib\pkgconfig


I don't know which win32-installer you're talking about (there's a bunch), but I use this:
http://sourceforge.net/projects/gladewin32
then select gtk+-win32-devel
Back to top
GTKNoob2008
Familiar Face


Joined: 09 Jul 2008
Posts: 6

PostPosted: Fri Jul 11, 2008 6:41 am    Post subject: Reply with quote

Hi,

i added the
Quote:
PKG_CONFIG_PATH
variable, but he throws the same message :roll: for
Quote:
pkg-config --cflags gtk+-2.0 > cflags.txt



i've loaded the following installers:
Quote:
glade-win32 3.4.3

and both
Quote:
gtk-dev-2.12.9-win32-1.exe
gtk-dev-2.12.9-win32-2.exe
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Fri Jul 11, 2008 5:08 pm    Post subject: Reply with quote

does the C:\GTK\lib\pkgconfig directory have the .pc files that it says it can't find?

also, you need to restart the command prompt after editing environment variables, so maybe it just hasn't updated yet?

(oh, and you should only need the gtk-dev-2.12.9-win32-2 one)
Back to top
GTKNoob2008
Familiar Face


Joined: 09 Jul 2008
Posts: 6

PostPosted: Tue Jul 15, 2008 9:45 am    Post subject: Reply with quote

hi dreblen,

i have reinstalled the package.

and now i get another message ...

Package pixman-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing 'pixman-1.pc'
to the PKG_CONFIG_PATH enviroment variable
Package 'pixman-1', required by 'cairo', not found....
Back to top
Vadi
GTK+ Geek


Joined: 28 May 2008
Posts: 68

PostPosted: Tue Jul 15, 2008 11:43 am    Post subject: Reply with quote

Heh, I remember getting the same error. I think I either fakes the .pc using one of the existing ones, or removed pixman from the requirements. I don't remember which.
Back to top
GTKNoob2008
Familiar Face


Joined: 09 Jul 2008
Posts: 6

PostPosted: Tue Jul 15, 2008 12:39 pm    Post subject: Reply with quote

Hi Vadi,

i have faked the .pc file and i than i get the two .txt files.

but after i added all to the enviroment and started a new cmd prompt and wanted to compile a testfile, he brings the same errors like before, but with a little difference that there is a new one in the first line.

Quote:
gcc : -WL, -luiid: No such file and directory
.... gtk.h ...

i think it will never run :(
Back to top
Vadi
GTK+ Geek


Joined: 28 May 2008
Posts: 68

PostPosted: Tue Jul 15, 2008 1:11 pm    Post subject: Reply with quote

Well it will at some point, I got it working... if you'd like, I can share my dev-cpp folder with you which has all of the gtk and glib stuffed into it that somehow works now.
Back to top
jsiebert



Joined: 16 Jul 2008
Posts: 1

PostPosted: Wed Jul 16, 2008 6:53 am    Post subject: Reply with quote

Good Morning everyone,

I'm also new to GTK+ on Windows. For the last few days I was also trying to get a simple GTK program running on Windows.
I got it working by using CMake as build-tool (actually a meta-build-tool). CMake generates Makefiles from very simple CMake-Makefiles (CMakeLists.txt). One can generate Makefiles for GNU/GCC based build environments (e.g. MinGW) as well as Visual Studio Project files.
My build environment is installed as follows:

- Install MinGW in C:\MinGW and add C:\MinGW\bin to PATH
- Install the GTK+ All-In-One bundle to C:\GTK and add C:\GTK\bin to PATH
- Install CMake (using the windows installer provied by them)

Next step is to write a CMakeLists.txt file for your project. There is an excellent documentation at the website of cmake but I can also provied a small example project if necessary.

Best regards,

Jens
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> General GTK+ Discussion All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP