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 

GTK installation in visual c++ and windows

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
hamid206
Familiar Face


Joined: 25 May 2007
Posts: 12

PostPosted: Wed May 30, 2007 1:32 am    Post subject: GTK installation in visual c++ and windows Reply with quote

What should I do and what shall I download in order to use gtk in windows xp
I use from visual c++ 2005 . what should I do if I want to introduce gtk to it?
I hope that my good friends will help me in this case as other cases.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 465
Location: Portland, OR USA

PostPosted: Wed May 30, 2007 5:16 am    Post subject: Reply with quote

I don't know how up-to-date it is, but, this article discusses it a bit: http://www.yolinux.com/TUTORIALS/GTK+ProgrammingTips.html
Back to top
xaos5
Familiar Face


Joined: 05 Nov 2006
Posts: 19

PostPosted: Thu May 31, 2007 5:48 am    Post subject: Reply with quote

That site looks pretty good, I usually just install gtk+ dev for win32 and make sure visual studio can find the files.
Back to top
xaos5
Familiar Face


Joined: 05 Nov 2006
Posts: 19

PostPosted: Mon Jun 18, 2007 5:53 am    Post subject: Reply with quote

Ok here is a quick setup guide:

Download the dev runtime: http://sourceforge.net/project/showfiles.php?group_id=98754&package_id=111411

create a new text file called gtk+_debug.vsprops:
Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
    ProjectType="Visual C++"
    Version="8.00"
    Name="gtk+ debug"
    >
    <Tool
        Name="VCCLCompilerTool"
        Optimization="0"
        AdditionalIncludeDirectories="$(INCLUDE)"
        RuntimeLibrary="3"
        StructMemberAlignment="4"
        AssemblerOutput="0"
        DebugInformationFormat="4"
    />
    <Tool
        Name="VCLinkerTool"
        AdditionalDependencies="art_lgpl_2.lib asprintf.lib atk-1.0.lib bz2.lib cairo.lib charset.lib croco-0.6.lib fontconfig.lib freetype.lib gdk_pixbuf-2.0.lib gdkglext-win32-1.0.lib gdk-win32-2.0.lib glade-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gsf-1.lib gsf-win32-1.lib gthread-2.0.lib gtkglext-win32-1.0.lib gtk-win32-2.0.lib iconv.lib intl.lib jpeg.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib png.lib popt.lib rsvg-2.lib tiff.lib xml2.lib z.lib"
        AdditionalLibraryDirectories="$(LIB)"
        GenerateDebugInformation="true"
        AssemblyDebug="1"
        GenerateMapFile="false"
        SubSystem="1"
        OptimizeForWindows98="1"
    />
</VisualStudioPropertySheet>


and another called gtk+_release.vsprops:
Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
    ProjectType="Visual C++"
    Version="8.00"
    Name="gtk+ release"
    >
    <Tool
        Name="VCCLCompilerTool"
        Optimization="2"
        FavorSizeOrSpeed="1"
        AdditionalIncludeDirectories="$(INCLUDE)"
        RuntimeLibrary="2"
        StructMemberAlignment="4"
        AssemblerOutput="0"
    />
    <Tool
        Name="VCLinkerTool"
        AdditionalDependencies="art_lgpl_2.lib asprintf.lib atk-1.0.lib bz2.lib cairo.lib charset.lib croco-0.6.lib fontconfig.lib freetype.lib gdk_pixbuf-2.0.lib gdkglext-win32-1.0.lib gdk-win32-2.0.lib glade-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gsf-1.lib gsf-win32-1.lib gthread-2.0.lib gtkglext-win32-1.0.lib gtk-win32-2.0.lib iconv.lib intl.lib jpeg.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib png.lib popt.lib rsvg-2.lib tiff.lib xml2.lib z.lib"
        AdditionalLibraryDirectories="$(LIB)"
        GenerateDebugInformation="false"
        AssemblyDebug="0"
        GenerateMapFile="false"
        SubSystem="2"
        OptimizeForWindows98="1"
    />
</VisualStudioPropertySheet>


Include both of these in your project (View -> Other Windows -> Property Manager), if vs still can't find gtk+ then add $(INCLUDE) and $(LIB) under the correct locations in Tools -> Options -> Projects and Solutions -> VC++ Directories


I made it so debug makes main the entry point and generates a console window also. Release needs to have a WinMain entry point like the following:
Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* Windows Specific Code */
#ifdef G_OS_WIN32
#include <windows.h>
int WINAPI WinMain(     
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
{
    return main (__argc, __argv);
}
#endif


If anybody tries this, let me know how it goes.

A quick tip: I personally think Lucida Console at Font Size 12 looks a lot better (ClearType enabled anyways).





CHANGES
06-19-07: added DebugInformationFormat="4" to debug sheet. Debugging works correctly now


Last edited by xaos5 on Tue Jun 19, 2007 4:41 am; edited 4 times in total
Back to top
xaos5
Familiar Face


Joined: 05 Nov 2006
Posts: 19

PostPosted: Mon Jun 18, 2007 6:08 am    Post subject: Reply with quote

Here is a simple gtk application to test with:
Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <gtk/gtk.h>

static void hello( GtkWidget *widget,
                   gpointer   data )
{
    g_print ("Hello World\n", data);
}

static gboolean delete_event( GtkWidget *widget,
                              GdkEvent  *event,
                              gpointer   data )
{
    g_print ("delete event occurred\n");

    return FALSE;
}

static void destroy( GtkWidget *widget,
                     gpointer   data )
{
    gtk_main_quit ();
}

int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
    GtkWidget *button;
   
    gtk_init (&argc, &argv);
   
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   
    g_signal_connect (G_OBJECT (window), "delete_event",
              G_CALLBACK (delete_event), NULL);
   
    g_signal_connect (G_OBJECT (window), "destroy",
              G_CALLBACK (destroy), NULL);
   
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
   
    button = gtk_button_new_with_label ("Hello World");
   
    g_signal_connect (G_OBJECT (button), "clicked",
              G_CALLBACK (hello), NULL);
   
    gtk_container_add (GTK_CONTAINER (window), button);
   
    gtk_widget_show (button);
   
    gtk_widget_show (window);
   
    gtk_main ();
   
    return 0;
}

/* Windows Specific Code */
#ifdef G_OS_WIN32
#include <windows.h>
int WINAPI WinMain(     
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
)
{
    return main (__argc, __argv);
}
#endif
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming 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