It is currently Sat Sep 26, 2020 1:21 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: GCC portable and GTK
PostPosted: Wed Nov 13, 2019 1:17 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4705
Location: Lyon - France
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:
#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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: GCC portable and GTK
PostPosted: Thu Nov 14, 2019 1:30 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4705
Location: Lyon - France
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:
; 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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye