GCC portable and GTK

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

GCC portable and GTK

Post by Kwai chang caine »

Hello at all :D

I try to understand something to the behaviour of GCC, and like i know they are numerous users of the "big father" of PB here 8) , i ask this question, because i have search a long time and that not always works :|

I want to have a windows GCC the most portable (Usb key) possible.
And i have not really understand how adding a library like GTK+ for example in portable version of C :oops:

So i have download "MinGW_6_3_0" in ZIP format, uncompresse it in the C:\
And do the same thing with "gtk+-bundle_2.24.10-20120208_win32" beside "MinGW" on C:\

I want try this simple code in "Fenetre_GTK_WIN.c" file :

Code: Select all

#include <gtk/gtk.h>
#include <pango/pango.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <atk/atk.h>

int main( int   argc, char *argv[] )
{
    GtkWidget *window;
    
    gtk_init (&argc, &argv);
    
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show  (window);
    
    gtk_main ();
    
    return 0;
}
So i open a cmd console and enter successively this commands :

Code: Select all

SET PATH=C:\MinGW\bin;%PATH%;

SET PATH=C:\gtk+;%PATH%

C:\MinGW\bin\gcc -o C:\CompilerEnC\Fenetre2_GTK_WIN.exe C:\CompilerEnC\Fenetre2_GTK_WIN.c -mms-bitfields -IC:/gtk+/include/gtk-2.0 -IC:/gtk+/lib/gtk-2.0/include -IC:/gtk+/include/atk-1.0 -IC:/gtk+/include/cairo -IC:/gtk+/include/gdk-pixbuf-2.0 -IC:/gtk+/include/pango-1.0 -IC:/gtk+/include/glib-2.0 -IC:/gtk+/lib/glib-2.0/include -IC:/gtk+/include -IC:/gtk+/include/freetype2/freetype -IC:/gtk+/include/libpng14 -LC:/gtk+/lib -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
And i have this answer :|
Compiler GCC wrote:C:\Users\Administrateur\AppData\Local\Temp\ccN9bwVz.o:Fenetre2_GTK_WIN.c:(.text+
0x34): undefined reference to `gtk_init_abi_check'
C:\Users\Administrateur\AppData\Local\Temp\ccN9bwVz.o:Fenetre2_GTK_WIN.c:(.text+
0x40): undefined reference to `gtk_window_new'
C:\Users\Administrateur\AppData\Local\Temp\ccN9bwVz.o:Fenetre2_GTK_WIN.c:(.text+
0x50): undefined reference to `gtk_widget_show'
C:\Users\Administrateur\AppData\Local\Temp\ccN9bwVz.o:Fenetre2_GTK_WIN.c:(.text+
0x55): undefined reference to `gtk_main'
collect2.exe: error: ld returned 1 exit status
Is it the good way ?
Have i missing something to do ?

Thanks and have a good day 8)
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: GCC portable and GTK

Post by Kwai chang caine »

I answer myself...
Finally thanks to Nituvious code, i have found a part of solution to my problem,
For have all the options of GCC, i use "pkg-config.exe"

If that can be usefull for someone :wink:

Code: Select all

; http://www.purebasic.fr/english/viewtopic.php?p=320659#p320659

Global hInput,wintitle.s

Procedure EnumWindProc(hwnd,*lpstring)
 stitle.s = Space(256)
 GetWindowText_(hwnd,@stitle,256)  
 str$ = PeekS(*lpstring) 
 If FindString(stitle,str$,1)
  ShowWindow_(hwnd,1)
  wintitle = stitle 
  hinput = hwnd 
  ProcedureReturn 0
 Else 
  ProcedureReturn 1
 EndIf   
EndProcedure   

Procedure SendConsole(szText.s)
 Static dosbox
 If wintitle = ""
  EnumWindows_(@EnumWindProc(),@"cmd.exe")
 Else 
  hinput = FindWindow_(0,wintitle)
 EndIf   
 
 If Not hinput 
  dosbox=RunProgram("cmd.exe", "", "")
  
  Delay(200)
  EnumWindows_(@EnumWindProc(),@"cmd.exe") 
 EndIf 
 
 If hinput
 
  szLength = Len(szText.s)
  
  For sz = 0 To szLength+1
   szCharacter$ = Mid(szText.s,sz+1,1)
   szLetterByLetter=Asc(szCharacter$)
   PostMessage_(hInput,#WM_CHAR,szLetterByLetter,0)
  Next
  
  PostMessage_(hInput,#WM_CHAR,13,0)
  Delay(500)
  
  
 EndIf 
 
EndProcedure

Source$ = "Fenetre_GTK_WIN"
CheminWin$ = GetPathPart(ProgramFilename())
CheminNux$ = ReplaceString(CheminWin$, "\", "/")

PkgConfig$ = "-mms-bitfields -I" + CheminNux$ + "GTK+/include/gtk-2.0 -I" + CheminNux$ + "GTK+/lib/gtk-2.0/include "
PkgConfig$ + "-I" + CheminNux$ + "GTK+/include/atk-1.0 -I" + CheminNux$ + "GTK+/include/cairo -I" + CheminNux$ + "GTK+/include/gdk-pixbuf-2.0 "
PkgConfig$ + "-I" + CheminNux$ + "GTK+/include/pango-1.0 -I" + CheminNux$ + "GTK+/include/glib-2.0 "
PkgConfig$ + "-I" + CheminNux$ + "GTK+/lib/glib-2.0/include -I" + CheminNux$ + "GTK+/include -I" + CheminNux$ + "GTK+/include/freetype2 "
PkgConfig$ + "-I" + CheminNux$ + "GTK+/include/libpng14 -L" + CheminNux$ + "GTK+/lib -lgtk-win32-2.0 -lgdk-win32-2.0 "
PkgConfig$ + "-latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 "
PkgConfig$ + "-lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl"

Gcc$ = CheminWin$ + "MinGW\bin\gcc -mwindows " + 
       CheminWin$ + "CompilerEnC\" + Source$ + ".c -o " + 
       CheminWin$ + "CompilerEnC\" + Source$ + ".exe"


SendConsole("SET PATH=C:\GCC\MinGW\bin;%PATH%;" + Chr(13))
Delay(500)
SendConsole("SET PATH=C:\GCC\gtk+\bin;%PATH%;" + Chr(13))
Delay(500)

SendConsole(Gcc$ + " " + PkgConfig$ + Chr(13))
ImageThe happiness is a road...
Not a destination
Post Reply