scorninpc / php-gtk3

GTK3 extension for PHP
https://andor.com.br/
GNU Lesser General Public License v3.0
118 stars 13 forks source link

Question about php-config in Makefile #136

Closed d47081 closed 3 months ago

d47081 commented 3 months ago

I'm using few php-gtk3 builds, and found that one of them does not work after build

Fatal error: Uncaught Error: Class "Gtk" not found

Suppose that because makefile linked to global php-config here:

https://github.com/scorninpc/php-gtk3/blob/master/Makefile#L110

I'm trying to add absolute (local version) path but it not works (maybe because of quotes, don't know)

Can be the reason?

Maybe it's better to add global variable like this one? https://github.com/CopernicaMarketingSoftware/PHP-CPP/blob/master/Makefile#L20

d47081 commented 3 months ago

I'm using this auto-build script for my app that replaces global php-config path to local one: https://github.com/YGGverse/Yoda/blob/main/INSTALL.sh#L198

It creates PHP/PHP-CPP/PHP-GTK dependencies in build folder inside the project dir.

it work before, until I've installed new PHP-GTK instance for global PHP version, now it say that Gtk class not found, I suppose that because PHP-GTK configured with wrong paths somewhere..

Now my app still work with global PHP but don't work with local PHP/PHP-CPP/PHP-GTK build, e.g.:

scorninpc commented 3 months ago

i dont see corelacionation between php-config and not load of extension @d47081

php-config are just used to install extension and headers

are you compiling with one version of php and running with another one?

/path/to/local/php -dextension=php-gtk3.so app.php - Gtk class not found

provide full output please

d47081 commented 3 months ago

So pkg-config is not globally called symlink here?

# https://github.com/scorninpc/php-gtk3/blob/master/Makefile#L110

GTKFLAGS            =   `pkg-config --cflags gtk+-3.0 gladeui-2.0 gtksourceview-3.0 ${MAC_INTEGRATIONFLAGS} ${LIBWNCKFLAGS}`
GTKLIBS             =   `pkg-config --libs gtk+-3.0 gladeui-2.0 gtksourceview-3.0 ${MAC_INTEGRATIONLIBS} ${LIBWNCKLIBS}`

are you compiling with one version of php and running with another one?

I'm compilling all PHP* dependencies into the local build folder (to not touch globals, and don't use sudo for install) but just installed php-gtk globally (for separated contribution tests) and now my local app builder does not work

like something calling to the globals in makefile yet

thanks for reply, maybe just builder issue if that is not common pkg-config location

d47081 commented 3 months ago

I'm using

INI_DIR     =   "/dev/null"

maybe reason in that?

anyway, php-config --ini-dir return empty result, so I don't know what to provide here

scorninpc commented 3 months ago

INI_DIR is only used to install

https://github.com/scorninpc/php-gtk3/blob/master/Makefile#L157

if you dont show me all the output, I really cannot help. If everyone can compile and run, it's work and you have or missing something, that I can just help if you help me to understant

scorninpc commented 3 months ago

I just can tell you, with this comment

php -dextension=php-gtk3.so app.php - OK /path/to/local/php -dextension=php-gtk3.so app.php - Gtk class not found

is that you are compilling php-gtk with global php, and not with /path/to/local/php, and, if you run /path/to/local/php -dextension=php-gtk3.so app.php the error maybe are "cannot load shared extension"

if is that case, you need to see the complete error to try solve, or compile to /path/to/local/php, not to global default php

d47081 commented 3 months ago

I don't really know where is the problem, because remember I have another mystics with rust dependencies on one machine, now this magic happened..

Closing so, will share my solution if found.

On laptop everything building well, I have no idea what is wrong with other PC..

d47081 commented 3 months ago

Found this output:

Warning: PHP Startup: php-gtk3: Unable to initialize module
Module compiled with module API=20220829
PHP    compiled with module API=20230831
These options need to match
 in Unknown on line 0

Fatal error: Uncaught Error: Class "Gtk" not found

It means that php-gtk3 configured with global php version 20220829 (php -i), not local one 20230831 (/local/php -i) I have provided LOCAL extension dir in makefile but it building with GLOBAL php version yet

EXTENSION_DIR       =   "/home/.../Yoda/build/Linux/opt/php/lib/php/extensions/no-debug-non-zts-20230831"

of course I have changed php_config path on php-cpp building.

upd just found php-cpp's ${PHP_CONFIG} --ldflags return empty path for my local php version

scorninpc commented 3 months ago

@d47081 i really need to see all complete message output!

like this:

image

I need to see command, i need to see full output

and please, provide output of -m, like this

image

d47081 commented 3 months ago

-m flags return nothing, I have only this output

Warning: PHP Startup: php-gtk3: Unable to initialize module
Module compiled with module API=20220829
PHP    compiled with module API=20230831
These options need to match
 in Unknown on line 0

Fatal error: Uncaught Error: Class "Gtk" not found

here is related issue but I don't understand where I must define my local php version for compiller - I've set local php-config path for php-cpp but can't find where can define for php-gtk3, it uses global php version yet and drop this error

https://github.com/CopernicaMarketingSoftware/PHP-CPP/issues/518

maybe I must to define INI_DIR? because local build has no path for it, and I've set there /dev/null

when I set -dextension="/absolute/path/to/php-gtk3.so" instead of -dextension="php-gtk3.so" still same, so target library linked properly

scorninpc commented 3 months ago

you still not sending me all, command and output

here you define php-config, but it's used only to see path to install, just it

php-gtk3 does not need php headers, its use php-cpp only

image

d47081 commented 3 months ago

I have correct EXTENSION_DIR path to local php-config version compilled. if php-gtk3 does not need php headers why I get alert about incorrect php-gtk3 API version?

You may try to build this app by INSTALL.sh and watch Makefiles generated in build/Linux/tmp for php-cpp/php-gtk3 https://github.com/YGGverse/Yoda#auto

scorninpc commented 3 months ago

You are installing PHP-CPP in a custom directory, https://github.com/YGGverse/Yoda/blob/main/INSTALL.sh#L15 without adding this to LD_LIBRARY_PATH, so when you compile PHP-GTK3, compiller will use /usr/lib one, not the compiled one

d47081 commented 3 months ago

Thanks but still can't make it working

trying to set in php-gtk makefile:

LINKER_DEPENDENCIES =   -L/path/to/build/Linux/usr/local/lib -lphpcpp ${GTKLIBS}

as defined in php-cpp makefile:

INSTALL_HEADERS         =   ${INSTALL_PREFIX}/include
INSTALL_LIB         =   ${INSTALL_PREFIX}/lib

and get same result

scorninpc commented 3 months ago

You can see search path priority. Compiler will use the first found

I can't help much, this is obviously a system/environment problem, but I believe this is the way to go

d47081 commented 3 months ago

Found this solution:

LINKER_DEPENDENCIES =   -Wl,-rpath=/path/to/build/Linux/usr/local/lib -lphpcpp ${GTKLIBS}

Thanks for help