Page 1 of 1

Crosscompilation Windows of GTK source for Raspberry

Posted: Wed Nov 27, 2019 1:41 pm
by Kwai chang caine
Hello at all

If by miracle, someone have already try to compil on windows a source code with GTK call for raspberry ?
I use for that "gcc-linaro-arm-linux-gnueabihf-4.8-2013.11_win32" without succes :oops:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>

int main(int argc, char *argv[])
{
    printf("La premiere fenĂȘtre Ă  RICO\n");

    /* Init GTK */
    gtk_init(&argc, &argv);

    /* Create main window */
    GtkWidget *main_window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(main_window),"La premiere fenetre a RICO");

    /* Connect exit signal */
    g_signal_connect(main_window,"delete-event",gtk_main_quit,NULL);

    /* Display window */
    gtk_widget_show_all(main_window);

    /* Run main loop */
    gtk_main();

    /* The following will be executed after the main loop ends */
    printf("Main loop exited\n");

    return 0;
}
Have a good day

Re: Crosscompilation Windows of GTK source for Raspberry

Posted: Thu Nov 28, 2019 9:37 am
by Joris
Hi Kwai chang caine,

I'm noob on this, but a Raspberry user, so...
What does your code do ?
What is it ment for ?

Thanks.

Re: Crosscompilation Windows of GTK source for Raspberry

Posted: Thu Nov 28, 2019 10:27 am
by Kwai chang caine
Hello JORIS 8)

I'm happy to see i'm not alone in this new adventure :D

Image

This is all the history :wink:
I love C since numerous years i know PB, but never dare to try to learn it, and like PB do all nearly like C for the little project, in fact i not see the real interest except the "pleasure" to begin this adventure :oops:

But in my job, my boss forced me to use RASPBERRY with PYTHON at the beginning :shock:
Like i have nerver see LINUX and PYTHON...for me it's the end of the world :lol:
Little bit by little bit, i begin to understand a little part of LINUX (Very little) :mrgreen:
I have try PYTHON and hate it :evil:

Then i have ask to my boss if i can use my love of C (Yes.... i know...i love something without know it) :oops:

But when you love a woman,

Image

you not know it too ....right :wink:
So between me and the C...it's the same thing ..

Image

It's "The unknown love" :mrgreen:

Then now ...for little KCC...

- It's the moment to know a little bit the linux world
- I have a good reason to learn my love of C
- I have a machine (raspberry) also big than my knowledge in programming :mrgreen:

But i have see, RASPBERRY is not really powerfull for programming on it :|
Better to use a real machine for compil, and after send the executable to RASP

Then i have read it's possible to crosscompil on windows a RASPBIAN executable :shock:
And it's really simple, because even KCC have understand, it's the real proof :mrgreen:

I want do that with the windows console, like this i can use the amazing code of the great INFRATEC for compil C source with my love PB :D
viewtopic.php?p=482009#p482009

For have all the parameters, i use for example

Code: Select all

C:\MinGW\bin\pkg-config --cflags --libs gtk+-2.0
On windows for compil a GTK application it's necessary to include all the GTK library in the std parameters
Then this is the "little" console command

Code: Select all

C:\MinGW\bin\gcc -mwindows C:\Fenetre2_GTK_WIN.c -o C:\Fenetre2_GTK_WIN.exe -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 -IC:/GTK+/include/libpng14  -LC:/GTK+/lib -lgtk-win32-2.0 -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 after......
"Roll my hen" (French expression "Roule ma poule" :wink:)

Image

I run this code and the miracle come, i have a nice Linux GTK window in WINDOWS :shock:

The problem his for crosscompil a RASPBIAN window on WINDOWS (Surely bad jealousy :mrgreen:)
I use for that "gcc-linaro-arm-linux-gnueabihf-4.8-2013.11_win32" a crosscompiler
For compil a simple C code, without external library all are done, just write this in WINDOWS console

Code: Select all

C:\gcc-linaro-arm-linux-gnueabihf-4.8-2013.11_win32\bin\arm-linux-gnueabihf-gcc.exe C:\HelloWord.c -o C:\HelloWord_RASP
That generate a real LINUX executable and that works very simply and well 8)

But the problem is for include an external big libray like GTK on my C code
when i do the same method of above, just replace the CGG compiler to the "arm-linux-gnueabihf-gcc.exe" compiler

Code: Select all

C:\arm-linux-gnueabihf-gcc.exe "C:\Fenetre1_GTK.c" -o "C:\Fenetre_GTK_NUX.nux" -IC:/gtk+-3.5.4-1-bundle/include/gtk-3.0 -IC:/gtk+-3.5.4-1-bundle/include/atk-1.0 -IC:/gtk+-3.5.4-1-bundle/include/cairo -IC:/gtk+-3.5.4-1-bundle/include/gdk-pixbuf-2.0 -IC:/gtk+-3.5.4-1-bundle/include/pango-1.0 -IC:/gtk+-3.5.4-1-bundle/include/glib-2.0 -IC:/gtk+-3.5.4-1-bundle/lib/glib-2.0/include -IC:/gtk+-3.5.4-1-bundle/include -IC:/gtk+-3.5.4-1-bundle/include/pixman-1 -IC:/gtk+-3.5.4-1-bundle/include/freetype2 -IC:/gtk+-3.5.4-1-bundle/include/libpng15  -Wl,-luuid -LC:/gtk+-3.5.4-1-bundle/lib -lgtk-3 -lgdk-3 -limm32 -lshell32 -lole32 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lfreetype -lfontconfig -lpango-1.0 -lm -lcairo -lgobject-2.0 -lglib-2.0 -lintl
That write thousand of error lines :shock:
WINDOWS console wrote:In file included from C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib/gal
loca.h:34,
from C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib.h:3
2,
from C:/gtk+-3.5.4-1-bundle/include/gtk-3.0/gdk/gdkco
nfig.h:13,
from C:/gtk+-3.5.4-1-bundle/include/gtk-3.0/gdk/gdk.h
:30,
from C:/gtk+-3.5.4-1-bundle/include/gtk-3.0/gtk/gtk.h
:30,
from C:\Fenetre1_GTK.c:3:

C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib/gtypes.h:476:33: warning:
return type defaults to 'int' [-Wimplicit-int]
# define GLIB_VAR extern __declspec(dllimport)
^~~~~~~~~~
C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib/gmem.h:276:1: note: in ex
pansion of macro 'GLIB_VAR'
GLIB_VAR gboolean g_mem_gc_friendly;
^~~~~~~~
In file included from C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib/gli
st.h:34,
from C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib/gha
sh.h:35,
from C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib.h:5
2,
from C:/gtk+-3.5.4-1-bundle/include/gtk-3.0/gdk/gdkco
nfig.h:13,
from C:/gtk+-3.5.4-1-bundle/include/gtk-3.0/gdk/gdk.h
:30,
from C:/gtk+-3.5.4-1-bundle/include/gtk-3.0/gtk/gtk.h
:30,
from C:\Fenetre1_GTK.c:3:

C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib/gmem.h: In function '__de
clspec':
C:/gtk+-3.5.4-1-bundle/include/glib-2.0/glib/gmem.h:280:10: error: exp
ected '=', ',', ';', 'asm' or '__attribute__' before 'GMemVTable'
GLIB_VAR GMemVTable *glib_mem_profiler_table;
^~~~~~~~~~
.........................
........................
etc ...thousands pages
And i not understand all of this text :oops:

Re: Crosscompilation Windows of GTK source for Raspberry

Posted: Thu Nov 28, 2019 12:28 pm
by Joris
Kwai chang caine wrote:Hello JORIS 8)
And i not understand all of this text :oops:
Just like me ;-).
You made a big job answering like this, but ... yeah.
I'm not into C and probably never will.
Python maybe, if I can't do my thing with that basic language available for RiscOs (also raspberry).

Thanks.

Re: Crosscompilation Windows of GTK source for Raspberry

Posted: Thu Nov 28, 2019 1:31 pm
by tj1010
Assuming whichever pre-build ARM gcc cross compiler you choose to use is setup right, then it should be as simple as building GTK and it's dependencies with it and using pkgconfig.

I won't lie I'm lazy and just ssh in to Gentoo on my banana pi m3 for arm gcc tasks.. Yesterday I started working on your problem under Debian on the x86-64 Windows 10 subsystem but ran out of time...

Code: Select all

dism /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux
reboot and install Debian from aka.ms/wslstore(78MB)
in cmd:

Code: Select all

bash
sudo apt update
sudo apt upgrade
sudo apt install gcc-arm-none-eabi
sudo apt autoremove
arm-none-eabi-gcc gtktest.c -o gtktest.arm
I didn't have time to build the entire gtk dependency tree for arm and didn't find it already done on the net. I did build your code with all of the gtk removed and it worked, though.. I'm pretty sure someone has already done it...

Re: Crosscompilation Windows of GTK source for Raspberry

Posted: Thu Nov 28, 2019 2:16 pm
by Kwai chang caine
@Nevermind JORIS :wink:
TJ1010 wrote: Yesterday I started working on your problem
That's very kind, thank you 8)
Because LINUX + C + GTK + ENGLISH it's really too much for my little head :oops: