Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-gtk3 for windows #24

Closed
subabrain opened this issue Nov 10, 2022 · 63 comments
Closed

php-gtk3 for windows #24

subabrain opened this issue Nov 10, 2022 · 63 comments

Comments

@subabrain
Copy link
Contributor

Hey there,

i got to compile phpcpp as a .lib / .dll file for windows.

here a link to the solution:

CopernicaMarketingSoftware/PHP-CPP#443

i am trying to compile php-gtk3 now with visual studio and phpcpp ..

But it is not very easy :/

Maybe someone could help - thanks a lot!

Greets
Robert

@scorninpc
Copy link
Owner

Hey Robert.

You are doing a lot nice work, thank you

What the problem or error? i dont have any windows machine that can i install and help, but i can try help if you show some erros and processes

Thank you

@subabrain
Copy link
Contributor Author

Hi,

i dont have problems with the libraries (i get them from vcpkg) - but with compiling errors ... i also tried to add the header files from glib/gtk/gdk and so on ... i will post the exact errors here later ...

Greets
Robert

@subabrain
Copy link
Contributor Author

ok here,

in c its:

c

and in c++:

c++

  • so if i take c there is no static function and in c++ there are no types ...

please help here :)

Greets
Robert

@scorninpc
Copy link
Owner

scorninpc commented Nov 12, 2022

why c++ has no types? everything is c++

C has no classes, so C is out of possible

I'm compiling with standard 11. can this be the problem? i think visual studio has 17 as default, if i'm not wrong

Try to add -std=c++11 as parameter in g++ compiler

edit:
I dont know, but i think the first print is a syntax error, and the second is a gtk lib reference problem

@subabrain
Copy link
Contributor Author

hi,

i think you misunderstood - i get this errors when compiling with the c / c++ language ...

but i will try one thing - i will report here ....

Greets
Robert

@subabrain
Copy link
Contributor Author

hi,

you cant compile gtk with g++ - you must compile as c

grafik

here is the c++ workaround:

https://www.gtk.org/docs/language-bindings/cpp

please help here!

Greets
Robert

@scorninpc
Copy link
Owner

scorninpc commented Nov 14, 2022

  • do you agree that C++ and C are the same language for any operating system?
  • do you agree that Gtk+ is C++, and it is a bind of GTK in C?
  • what compiler are you using? MSVC? do you agree that if on linux and mac g++ compiles, the problem may be in the MSVC compiler?

here is the c++ workaround:
https://www.gtk.org/docs/language-bindings/cpp

This is not workaround, this is a language bind for C++, as there is a language bind for python, Go and more. The PHP-GTK is not a bind of GTKMM, this is a bind on GTK =)

Please, try provide your environment. What compiller, what steps, what erros .....

@subabrain
Copy link
Contributor Author

hi,

i fully agree :)

Greets
Robert

@subabrain
Copy link
Contributor Author

Hi there,

ok - i think i figured out ... it has to do with the glib dependencies ...

maybe someone could help / explain me what to do?

Greets
Robert

@scorninpc
Copy link
Owner

The better way to try, maybe be do some simple projects with GTK, without PHP, to know dependencies of GTK on windows. After you compile a simple hello world with GTK, you know dependencies, and can add this to PHP-GTK

@subabrain
Copy link
Contributor Author

Hi,

okay - its a good way :)

i will try later :)

Greets
Robert

@subabrain
Copy link
Contributor Author

subabrain commented Nov 22, 2022

Hi,

ok, im very far now ... maybe one question:

where is the type "GType" defined?

i searched but its not working .... with the:

#include "glib/gtypes.h"
#include "glib/glib.h"
#include "gobject/gtype.h"
#include "gobject/gobject.h"
#include "glib/glib-object.h"

Greets
Robert

@scorninpc
Copy link
Owner

@subabrain
Copy link
Contributor Author

here

image

Greets
Robert

@scorninpc
Copy link
Owner

scorninpc commented Nov 22, 2022

ah ok

This is defined on gtk.h , that include gobject.h, that include gtype.h

That's why i'm suspecting that your environment is missing something

@subabrain
Copy link
Contributor Author

hi,

okay - i fixed now the gtype stuff :)

image

Greets
Robert

@subabrain
Copy link
Contributor Author

subabrain commented Dec 9, 2022

hi,

okay - i think i got it now ... just compile it like this:

https://www.proggen.org/doku.php?id=c:tutorial:libraries:visualstudio

then just add the .dll of phpcpp to your project and then compile with visual studio :)

Greets
Robert

@subabrain
Copy link
Contributor Author

subabrain commented Dec 12, 2022

hi,

for all others - the problem was the glib dependencies in visual studio ...

this helps a lot:

http://www.tarnyko.net/dl/gtk.htm

Greets
Robert

@subabrain
Copy link
Contributor Author

here a result from gtk with visual studio:

grafik

@subabrain
Copy link
Contributor Author

Now just put the parts together for phpgtk 📦

Greets
Robert

@subabrain
Copy link
Contributor Author

subabrain commented Dec 13, 2022

ok -i got to compile but im linking at the moment :P

(i try to make 64 bit) :)

Greets
Robert

@subabrain
Copy link
Contributor Author

subabrain commented Dec 16, 2022

ok - i will post today evening the .dll ... and an explanation how to compile with visual studio :)

EDIT: Sorry i have problems with 64 bit - i will do 32 ;)

Greets
Robert

@scorninpc
Copy link
Owner

scorninpc commented Dec 17, 2022

thats run a simple gtkwindow? =D veeeery nice

@subabrain
Copy link
Contributor Author

thats run a simple gtkwindow? =D veeeery nice

what you mean exactly?

Greets
Robert

@scorninpc
Copy link
Owner

ok - i will post today evening the .dll ... and an explanation how to compile with visual studio :)

did you compiled and run any php-gtk test? its working?

@subabrain
Copy link
Contributor Author

subabrain commented Dec 17, 2022

ok - i will post today evening the .dll ... and an explanation how to compile with visual studio :)

did you compiled and run any php-gtk test? its working?

EDIT: It compiles and links correct but i have problems to get it to run as extension .......

you can compile/link yourself -> all you need is msys2 and a working sourcecode version of phpcpp like posted above by y´myself ....

Good Luck!

I will let you know if it works :P

Greets
Robert

@subabrain
Copy link
Contributor Author

hi,

ok - i got it but i dont see any window :P - tell me please if this is maybe because of the php version?

i took php 7.4.0?

Greets
Robert

@scorninpc
Copy link
Owner

i need to see your php code to tell something to you

when you run php -m gtk is on the list?

@subabrain
Copy link
Contributor Author

here:

grafik

i will post tomorrow ...

Greets
Robert

@scorninpc
Copy link
Owner

Nice, you done it

Now you can run

<?php

Gtk::init();

function GtkWindowDestroy($widget=NULL, $event=NULL)
{
	Gtk::main_quit();
}

$win = new GtkWindow();
$win->set_default_size(300, 200);
$win->connect("destroy", "GtkWindowDestroy");
$win->show_all();

this need to open a blank window

image

@scorninpc
Copy link
Owner

scorninpc commented Dec 21, 2022

Very nice! i'll create a VM this weekend to test this. If you provide the steps to compile, i'll update documentation and try compile too

Thank you for your perseverance =D

@subabrain
Copy link
Contributor Author

Hi Bruno,

ok .. i will do it later ;)

Greets
Robert

@subabrain
Copy link
Contributor Author

Hi,

can i make a repository for phpgtk3 (windows) with visual studio here at github?

thanks a lot!

Greets
Robert

@scorninpc
Copy link
Owner

i think we need use the same, for the updates

fork and do a PR with your changes

@subabrain
Copy link
Contributor Author

hi,

ok - i see - we will do :)

Greets
Robert

@subabrain
Copy link
Contributor Author

Ok here,

a little Tutorial about Compiling PHP-GTK3 for Windows with Visual Studio :)

Please give Response :)

Compile.docx

Greets
Robert

@scorninpc
Copy link
Owner

Robert, you do a nice work

I'll translate it to here ok?

@subabrain
Copy link
Contributor Author

Robert, you do a nice work

I'll translate it to here ok?

its ok ;)

Greets
Robert

@scorninpc
Copy link
Owner

This a lot work hahaha https://github.com/scorninpc/php-gtk3/blob/master/docs/compile-windows.md

Now i'll make a Windows VM to test your .zip file

@subabrain
Copy link
Contributor Author

Ok,

good luck! - please dont forget to install the redists ...

Greets
Robert

@scorninpc
Copy link
Owner

I'm totaly noob on windows
image

@subabrain
Copy link
Contributor Author

subabrain commented Dec 24, 2022

Ok,

EDIT:

You must copy these files from the msys "bin" folder to your PHP binary root folder:

libatk-1.0-0.dll
libbrotlicommon.dll
libbrotlidec.dll
libbrotlienc.dll
libbz2-1.dll 
libcairo-2.dll
libcairo-gobject-2.dll
libdatrie-1.dll
libepoxy-0.dll
libexpat-1.dll
libffi-8.dll
libfontconfig-1.dll
libfreetype-6.dll 
libfribidi-0.dll
libgcc_s_seh-1.dll
libgdk-3-0.dll
libgdk-win32-2.0-0.dll
libgdk_pixbuf-2.0-0.dll
libgio-2.0-0.dll
libglade-2.0-0.dll
libgladeui-2-13.dll
libglib-2.0-0.dll
libgmodule-2.0-0.dll
libgmpxx-4.dll
libgobject-2.0-0.dll
libgraphite2.dll
libgthread-2.0-0.dll
libgtk-3-0.dll
libgtk-win32-2.0-0.dll
libgtksourceview-3.0-1.dll
libharfbuzz-0.dll
libharfbuzz-gobject-0.dll
libiconv-2.dll
libintl-8.dll
liblzma-5.dll
libpango-1.0-0.dll
libpangocairo-1.0-0.dll
libpangoft2-1.0-0.dll
libpangowin32-1.0-0.dll
libpcre2-8-0.dll
libpixman-1-0.dll
libpng16-16.dll
libproxy-1.dll
librsvg-2-2.dll
libssl-1_1-x64.dll
libstdc++-6.dll
libsystre-0.dll
libtasn1-6.dll
libtermcap-0.dll
libthai-0.dll 
libunistring-2.dll
libwinpthread-1.dll
libxml2-2.dll
libzstd.dll
zlib1.dll

Greets
Robert

@subabrain
Copy link
Contributor Author

subabrain commented Dec 24, 2022

Hi,

okay - please try this one:

https://1drv.ms/u/s!AifVi84AXOwIhZR28F7EKuSOFAsuFg?e=uiPT5S

Thanks!

Merry Christmas!
Robert

PS: @scorninpc please tell me if its working for you now ... thx!

@scorninpc
Copy link
Owner

okay - please try this one:

https://1drv.ms/u/s!AifVi84AXOwIhZR28F7EKuSOFAsuFg?e=uiPT5S

Yes, it's working

Capturar_select-area_20221226112716

Capturar_select-area_20221226112856

You must copy these files from the msys "bin" folder to your PHP binary root folder:

Ok, i've updated the documentation

I found a little problem with pixbuf icons and images

Capturar_select-area_20221226112922

I think the problem 1 are that cannot find stock icons. Try to run this example

The second problem, i dont know why, PHP cannot find my image

image

This is the example i'm running

<?php

Gtk::init();

function GtkWindowDestroy($widget=NULL, $event=NULL)
{
	Gtk::main_quit();
}

echo "\n\n";
echo getcwd() . "\n";
echo "\n\n";
echo system('dir') . "\n";
echo "\n\n";

$win = new GtkWindow();
$win->set_default_size(300, 200);
$win->connect("destroy", "GtkWindowDestroy");

$img = GtkImage::new_from_file("C:\\Users\\admin\\Desktop\\examples\\twitter.png");

$btn = new GtkButton("Tw");
$btn->set_image($img);

$win->add($btn);
$win->show_all();


Gtk::main();

Anyway, you dont know how i'm happy to run a example on windows hahahah

@subabrain
Copy link
Contributor Author

subabrain commented Dec 26, 2022

Hi,

ok i see ... i will have a look!

EDIT: Ok i found something in the header file: gdk-pixbuf-transform.h - i will have a look .... give me some time ;)

-> Ok i found it - the placement of the "glibconfig.h" was not in the "glib" folder .... i think we have to update the tutorial again 😄

Greets
Robert

@scorninpc
Copy link
Owner

scorninpc commented Dec 26, 2022

I think that are 2 problems

1 - I dont know why it cannot find my image
2 - When it not find my image, they try to add a broken image icon, so the icons of pixbuf are not on zip package

For the first one, i really dont understand. I've done all tests I can, but no success

For second, maybe add the icons anywhere and add it to path, maybe works. I'll do a installer after package are OK, so dont worry with that "manual action" ok?

EDIT:

-> Ok i found it - the placement of the "glibconfig.h" was not in the "glib" folder .... i think we have to update the tutorial again smile

Sorry, i didn't see this =D

@scorninpc
Copy link
Owner

I solved creating the cache with gdk-pixbuf-query-loaders --update-cache and copy c:\msys64\mingw64\lib\gdk-pixbuf-2.0 to PHP_DIR/lib/

image

This can be a right way?

@scorninpc
Copy link
Owner

Appear to works fine! From png, from jpeg and theme name

image

@subabrain
Copy link
Contributor Author

👍 👍 👍

@subabrain
Copy link
Contributor Author

Hi,

ok - please add your adjustments to the Tutorial and please update - to put the file "glibconfig.h" from the folder "mingw64\lib\glib-2.0\include" to the folder "mingw64\include\glib-2.0". And update the Preprocessor to:

%(PreprocessorDefinitions)
_WINDOWS
_WIN32
NDEBUG
ZEND_DEBUG=0
_CRT_SECURE_NO_WARNINGS
PHP_WIN32
ZEND_WIN32
_MSC_VER=1934
PHP_COMPILER_ID="VC15"
_CRT_NONSTDC_NO_DEPRECATE
_NOEXCEPT=noexcept
G_PLATFORM_WIN32
GIO_COMPILATION
BUILDING_PHPCPP
PHP_VERSION_ID=70300
GDK_PIXBUF_COMPILATION
GDK_COMPILATION
GTK_COMPILATION
GLIB_COMPILATION

Thanks a lot!

Greets
Robert

@subabrain
Copy link
Contributor Author

Hello @ALL,

i saw, that there is a folder needed - the name is "share" and it is located in the root dir of php ... i packed now all together so this version should work for you :)

https://1drv.ms/u/s!AifVi84AXOwIhZR53jkm-y4JrCYkoA?e=HchNmt

Have Fun!

Notice: Please tell me if its working for you all 😃

Greets
Robert

@scorninpc
Copy link
Owner

Works fine, but what version of GTK are you using? The icon theme are the correct version?

Look GtkSpinner for example. Its added to 3.24. The example works fine but without loading icon

image

With my Adwaita icon theme, its appear, look:

image

@scorninpc
Copy link
Owner

to put the file "glibconfig.h" from the folder "mingw64\lib\glib-2.0\include" to the folder "mingw64\include\glib-2.0"

Where i can put this on the tutorial? GTK Dependencies section?

@subabrain
Copy link
Contributor Author

hi,

ok try this one:

https://1drv.ms/u/s!AifVi84AXOwIhZR7hxFQVXNOWa-WRA?e=2SXQt8

Greets
Robert

@subabrain
Copy link
Contributor Author

to put the file "glibconfig.h" from the folder "mingw64\lib\glib-2.0\include" to the folder "mingw64\include\glib-2.0"

Where i can put this on the tutorial? GTK Dependencies section?

yes just put it there as first point (GTK Dependencies) .... thx!

Greets
Robert

@scorninpc
Copy link
Owner

ok try this one:

Appear to be ok

image

yes just put it there as first point (GTK Dependencies) .... thx!

Ok, updated

Can I add this build to be downloaded on release page?

Another question: its easy to try with PHP 8.1.14? maybe some PR of PHP-CPP needed to be merged manually, but you think its can be done? if its a problem for you, I'll try to follow the steps

@subabrain
Copy link
Contributor Author

ok try this one:

Appear to be ok

image

yes just put it there as first point (GTK Dependencies) .... thx!

Ok, updated

Can I add this build to be downloaded on release page?

Another question: its easy to try with PHP 8.1.14? maybe some PR of PHP-CPP needed to be merged manually, but you think its can be done? if its a problem for you, I'll try to follow the steps

Hi,

yes of course you can add this build 👍

yes its possible to do with PHP 8 - but you have to compile it new with the sources and binaries for PHP 8.

i will have a look :)

Greets
Robert

@scorninpc
Copy link
Owner

Nice Robert

So I think i'll close this issue, and open another for PHP 8.1 ok? Now we have a official windows package =)

Thank you alot

@subabrain
Copy link
Contributor Author

Nice Robert

So I think i'll close this issue, and open another for PHP 8.1 ok? Now we have a official windows package =)

Thank you alot

Hi,

yes of course ;)

Greets
Robert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants