CopernicaMarketingSoftware / PHP-CPP

Library to build PHP extensions with C++
http://www.php-cpp.com/
Apache License 2.0
1.43k stars 333 forks source link

Error when compiling PHP-CPP with Debian and MingW newest Version #443

Open subabrain opened 4 years ago

subabrain commented 4 years ago

Hello,

i tried now several days to compile php-cpp in Debian with MingW (newest Version). And there are Errors like:

...

/usr/i686-w64-mingw32/include/phpcpp/inivalue.h:17:21: error: variable ‘Php::PHPCPP_EXPORT Php::IniValue’ has initializer but incomplete type class PHPCPP_EXPORT IniValue

...

And if i try to compile with g++ - it works..

Please help me!

Thanks!

subabrain commented 4 years ago

ok .. i dont get this with this version:

git clone https://github.com/CopernicaMarketingSoftware/PHP-CPP.git

this works :)

subabrain commented 4 years ago

sorry i am wrong - it doesnt work :/

here one error: ... EDIT:

error: expected initializer before ‘__THROW’ extern void *alloca (size_t size) THROW;

....

please help :)

scorninpc commented 4 years ago

That's the problem

https://stackoverflow.com/questions/3711327/how-do-you-compile-a-php-extension-on-windows-with-cygwin-mingw

subabrain commented 4 years ago

Thanks Bruno - ill give a try :)

subabrain commented 4 years ago

ok .. but i dont understand whats this feature has to say:

This release is mainly a bugfix release

i think its because of a compiler error ....

subabrain commented 2 years ago

hi,

here the .dll from phpcpp and the .lib - compiled with php 7.4.0 / x86 and phpcpp :)

Release.zip

EDIT: now it should work :)

Greets Robert

scorninpc commented 2 years ago

Man! This is a great news. I'll try it as i can. Thank you

subabrain commented 2 years ago

Hi,

sorry there are 4 dependencies which are not working (but the rest :) ) -i dont know why - i will check today evening ..

Greets Robert

subabrain commented 2 years ago

Hi,

ok i got it - its working now .... :)

grafik

Greets Robert

subabrain commented 2 years ago

i will upload a .sln Project here later ;)

Greets Robert

subabrain commented 2 years ago

ok - my example extension works - without errors with phpcpp (with windows) :)

i now try the php-gtk3 ;)

Greets Robert

scorninpc commented 2 years ago

This is the best news on this year

If you compile on windows, i'll back on the project, creating an auto-generator to create all the methods, and will be my year end project

Please, try to write steps to compile php-cpp on windows, 'ill help alot

subabrain commented 2 years ago

This is the best news on this year

If you compile on windows, i'll back on the project, creating an auto-generator to create all the methods, and will be my year end project

Please, try to write steps to compile php-cpp on windows, 'ill help alot

Hi Bruno,

EDIT:

you have to rename the "string.h" file in the "zend" phpcpp folder to f.e. "strings.h" - because if you dont do this there are some errors because conflicts of the system "string.h" file ...... and then rename this string.h to strings.h when needed :)

but i will try but not with fixed sourcecode - this would be too much - but i will upload the .sln File with the fiexed files here later:

  1. make a new empty c++ project in visual studio (i took version 2022 community)

  2. download the phpcpp sourcecode (i took the newest on github)

  3. download the php sourcecode (i took php 7.4.0 from gihtub releases)

  4. download the php binaries for windows (i took php 7.4.0 x86 non thread safe):

    https://windows.php.net/downloads/releases/archives/php-7.4.0-nts-Win32-vc15-x86.zip

  5. put them extracted in a folder...

  6. now choose your environment in visual studio to "Release" and "X86" (not tested with X64)

  7. please add then all files from the "zend" directory of phpcpp as .cpp files to your project ..

  8. now make the include paths in "properties" of the project to the following php paths in visual studio: ... php_source_path\php-src-php-7.4.0 php_source_path\php-src-php-7.4.0\main php_source_path\php-src-php-7.4.0\Zend php_source_path\php-src-php-7.4.0\TSRM php_source_path\php-src-php-7.4.0\ext php_source_path\php-src-php-7.4.0\build\main php_source_path\php-src-php-7.4.0\build\Zend ...

  9. And important - do the following with the preprocessor definitions:

    _WIN32 _WINDOWS NDEBUG ZEND_DEBUG=0 _CRT_SECURE_NO_WARNINGS BUILDING_PHPCPP ZEND_WIN32_KEEP_INLINE PHP_WIN32 ZEND_WIN32 _USE_32BIT_TIME_T _MSC_VER=1933 PHP_COMPILER_ID="VC15"

  10. Now - set the Linker options to:

    php7.lib

  11. then set the path of the Linker to:

    php_source_path\php-7.4.0-nts-Win32-vc15-x86\dev

    so the php7.lib located in the "dev" folder ...

  12. now compile the project - BUT you have to choose the version of build to plattform Visual Studio 2017 (v141)

  13. and choose the c++ compiler to "iso17"

so now if its compiled you can use it for developing extensions from php in windows :)

the sln project with all dependencies are comming later ;)

Greets from Germany Robert

subabrain commented 2 years ago

Hi,

the Problem in phpgtk3 for windows is the mixture of c and c++ - its not easy 😢

but not for me 😄

Greets Robert

subabrain commented 2 years ago

Hi,

here the .sln file for compiling phpcpp under windows ....

EDIT:

https://1drv.ms/u/s!AifVi84AXOwIhZRdiS8uKQUCQy5i9Q?e=EpJkE5

NOTE:

You have to adjust the c++ files path ... or just add them by yourself :)

HAVE FUN!

Greets Robert

subabrain commented 2 years ago

@scorninpc - maybe you can support me in compiling php-gtk3 for windows with help of my compiled phpcpp version ...

Thanks and Greets! Robert

scorninpc commented 2 years ago

For sure Robert! Open a issue on the php-gtk3 project