Comments (21)
Hi @walker-walks, in order to get this compiled, you need to have php
installed as a library.
To do this on MacOS, you need to get Homebrew installed, if you haven't yet, then install PHP:
brew install -v homebrew/php/php70 --enable-embed=shared
However, I haven't tested this on MacOS so YMMV. You will most likely need to add the full path to the include/php7
directory that Brew uses into the php7.go
file, or wait for a branch for adding MacOS support.
from go-php.
I installed php shared library and added the full path.
now the error appears like this.
# github.com/deuill/go-php/engine
In file included from engine/engine.go:14:
In file included from include/receiver.h:15:
include/php5/_receiver.h:8:72: error: unknown type name 'zend_literal'; did you mean 'zend_label'?
static zval *_receiver_get(zval *object, zval *member, int type, const zend_literal *key);
^~~~~~~~~~~~
zend_label
/usr/local/Cellar/php70/7.0.7/include/php/Zend/zend_compile.h:179:3: note: 'zend_label' declared here
} zend_label;
^
In file included from engine/engine.go:14:
In file included from include/receiver.h:15:
include/php5/_receiver.h:9:74: error: unknown type name 'zend_literal'; did you mean 'zend_label'?
static void _receiver_set(zval *object, zval *member, zval *value, const zend_literal *key);
^~~~~~~~~~~~
zend_label
/usr/local/Cellar/php70/7.0.7/include/php/Zend/zend_compile.h:179:3: note: 'zend_label' declared here
} zend_label;
^
In file included from engine/engine.go:14:
In file included from include/receiver.h:15:
include/php5/_receiver.h:10:74: error: unknown type name 'zend_literal'; did you mean 'zend_label'?
static int _receiver_exists(zval *object, zval *member, int check, const zend_literal *key);
^~~~~~~~~~~~
zend_label
/usr/local/Cellar/php70/7.0.7/include/php/Zend/zend_compile.h:179:3: note: 'zend_label' declared here
} zend_label;
^
In file included from engine/engine.go:14:
In file included from include/receiver.h:15:
include/php5/_receiver.h:13:86: error: unknown type name 'zend_literal'; did you mean 'zend_label'?
static zend_function *_receiver_method_get(zval **object, char *name, int len, const zend_literal *key);
^~~~~~~~~~~~
zend_label
/usr/local/Cellar/php70/7.0.7/include/php/Zend/zend_compile.h:179:3: note: 'zend_label' declared here
} zend_label;
^
In file included from engine/engine.go:14:
In file included from include/receiver.h:15:
include/php5/_receiver.h:17:8: error: unknown type name 'zend_object_value'
static zend_object_value _receiver_init(zend_class_entry *class_type);
^
5 errors generated.
from go-php.
Did you build with -tags php7
?
i.e.:
go build -tags php7
Unfortunately, you'll have to pass that in any build command that includes go-php
, even things that just include it as a dependency. PHP 7.x has been out for a while now, though, so I may just change the default and have PHP 5.x require a tag instead.
from go-php.
I was not using build tags.
With -tags php7
appears like below.
github.com/deuill/go-php/engine
# github.com/deuill/go-php/engine
In file included from engine/context.go:12:
include/context.h:17:10: fatal error: '_context.h' file not found
#include "_context.h"
^
1 error generated.
from go-php.
I believe you may have accidentally removed the following:
#cgo CFLAGS: -Iinclude/php7 -Isrc/php7
Which defines the include paths for the local PHP 7.x headers.
from go-php.
I did the whole process from downloading the "go-php" library and I've got the same error message.
In file included from engine/context.go:12:
include/context.h:17:10: fatal error: '_context.h' file not found
#include "_context.h"
^
1 error generated.
I'm thinking that OS X version of php is very strange because instead of installing in include/php7
dir it's installed in /usr/local/Cellar/php70/7.0.7/include
dir (maybe cos the rootless problem?).
And I couldn't find _context.h
file in any version of php installed.
from go-php.
The _context.h
file is a local include here, and does not belong to PHP itself, hence why you need those relative paths I commented on above, in addition to the absolute paths to /usr/local/Cellar/php70/7.0.7/include
etc.
I'll see if I can find a MacOS machine to test support on.
from go-php.
I think I got that part.. Now I have another message.
Let me organize what I've done until now.
At first when I just finished to download and do go build -tags php7
I get this message.
# github.com/deuill/go-php/engine
engine/context.go:11:11: fatal error: 'main/php.h' file not found
#include <main/php.h>
^
1 error generated.
so I change engine/context.go
file's import with full path
// #cgo CFLAGS: -I/usr/local/Cellar/php70/7.0.7/include/php -I/usr/local/Cellar/php70/7.0.7/include/php/main -I/usr/local/Cellar/php70/7.0.7/include/php/TSRM
// #cgo CFLAGS: -I/usr/local/Cellar/php70/7.0.7/include/php/Zend -Iinclude
The new part is here. this is the new message I've got.
github.com/deuill/go-php/engine
# github.com/deuill/go-php/engine
engine/engine.c:43:10: warning: enumeration values 'SAPI_HEADER_DELETE_ALL' and 'SAPI_HEADER_SET_STATUS' not handled in switch [-Wswitch]
# github.com/deuill/go-php/engine
engine/receiver.c:79:1: warning: control reaches end of non-void function [-Wreturn-type]
# github.com/deuill/go-php/engine
engine/value.c:121:47: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'zend_ulong *' (aka 'unsigned long long *') [-Wincompatible-pointer-types]
include/php7/_value.h:14:87: note: passing argument to parameter 'num_index' here
# github.com/deuill/go-php/engine
ld: library not found for -lphp7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
from go-php.
You're getting there! Final piece (hopefully) would require that you go into php7.go
and change that line to this (or similar):
// #cgo LDFLAGS: -L/usr/local/Cellar/php70/7.0.7/lib -lphp7
I assume that's where Homebrew installs the PHP libraries.
from go-php.
The lib path is that you wrote.
I'm tried adding the path but doesn't compile. so I tried changing the depth of the path like
<path from root>/lib
, <path from root>/lib/php
, <path from root>/lib/php/build
but still getting the same message.
from go-php.
It may be that Homebrew installs the libraries as libphp.so
and not libphp7.so
. Check the relevant folders and see what the name of the .so
libraries are. The convention is, a -lphp7
declaration corresponds to a file named libphp7.so
, and so forth.
from go-php.
inside lib
dir looks like this
/lib
└── php
└── build
├── Makefile.global
├── acinclude.m4
├── config.guess
├── config.sub
├── libtool.m4
├── ltmain.sh
├── mkdep.awk
├── phpize.m4
├── run-tests.php
├── scan_makefile_in.awk
└── shtool
next lib
dir there is a libexec
dir which contains apache2/libphp7.so
So I tried variations like
// #cgo LDFLAGS: -L/usr/local/Cellar/php70/7.0.7/libexec/ -lphp7
// #cgo LDFLAGS: -L/usr/local/Cellar/php70/7.0.7/libexec/apache2 -lphp7
but results the same.
from go-php.
Bah, how stupid. It appears that Homebrew does not support building PHP as a shared library. I assumed passing the --enable-embed=shared
option, which works for the PHP source, would be passed in and the libraries installed correctly; it is not.
These are your choices:
- Fix the Homebrew recipe for
php-embed
. - Build and install PHP from source with the above option, in which case you probably don't need the path hacks above. There's probably some tutorial out there to help out.
- Build and develop in a Linux container/VM.
from go-php.
yah, actually I couldn't notice that. brew didn't give me any feedback..
I don't understand properly about brew.
And I guess docker/VM will not help much. I heard cgo has cross compile difficulty.
I'm going to try compiling from source.
from go-php.
hi, I built php from source. Now I have embed lib files but still I have a similar message.
I'm thinking to give up and look for another away.
engine/engine.c:43:10: warning: enumeration values 'SAPI_HEADER_DELETE_ALL' and 'SAPI_HEADER_SET_STATUS' not handled in switch [-Wswitch]
engine/engine.c:97:2: warning: incompatible pointer types initializing 'void (*)(char *, int)' with an expression of type 'void (char *)' [-Wincompatible-pointer-types]
# github.com/deuill/go-php/engine
engine/receiver.c:79:1: warning: control reaches end of non-void function [-Wreturn-type]
# github.com/deuill/go-php/engine
engine/value.c:121:47: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'zend_ulong *' (aka 'unsigned long long *') [-Wincompatible-pointer-types]
include/php7/_value.h:14:87: note: passing argument to parameter 'num_index' here
# github.com/deuill/go-php/engine
ld: library not found for -lphp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
from go-php.
Hi guys, how did you succeed to build PHP from source on OS X with "--enable-embed=shared"? I constantly got bunch of errors like this:
clang: error: ext/date/php_date.o: No such file or directory
Tried different ways but still no luck.
from go-php.
I'm not sure if PHP can be built with Clang. If anything, there's probably documentation out there on how to build.
The real outcome of this is I should probably provide binary packages built against PHP statically, but I need to confirm with the PHP license before I can do that.
from go-php.
I built with gcc-6 too, there are some problems with .o / .dyld file locations on OS X when building with "--enable-embed=shared" option. It is a known bug at PHP.net, but nobody cares. If you could, please release static binary, because "shared PHP" is quite hard to achieve on OS X.
Thanks a lot for the package though :)
from go-php.
Hi, I could build PHP on Mac but the problem was to link these files and build with go.
now I'm going to look for a way to link ".so" files. I'm not sure if it's possible but could be another way.
thanks for the help @deuill
from go-php.
@walker-walks Could you tell how did you compile the PHP in shared mode on OS X, please?
from go-php.
Hi @aaxx . To be honest I don't remember exactly. I mixed up some tutorials to do that.
This is what I remember.
- Download PHP source file from the official.
- configure the make file with build options. like below.
./configure \
--enable-mod-charset \
--with-config-file-path=/etc \
--with-apxs2=/usr/sbin/apxs \
--disable-cgi \
--with-libexpat-dir=/usr \
--with-libxml-dir=/usr \
--with-openssl \
these options are just an example, for detail you can check here.
- after configuring make file you do
make
,make test
andmake install
.
I think it was something like this.
from go-php.
Related Issues (20)
- php7.2 install error HOT 1
- Install problem HOT 1
- Read globals (`$_GET`, `$_POST`, `$_FILES`, `$_REQUEST`, etc) from `http.Request` types HOT 2
- can you show more code example? HOT 3
- Error while getting dependencies HOT 1
- Portability HOT 24
- Long running PHP script HOT 5
- library not found for -lphp7 HOT 1
- Unexpected signal during runtime execution HOT 6
- maxos make install fail
- warning
- would this package profit from this? HOT 1
- Compilation Error HOT 2
- Confused about PHP7/ZTS HOT 1
- Compile Error On Mac OS Catalina HOT 1
- Status of the project? HOT 2
- PHP 8.1.3 HOT 3
- possible to use php on go gin project HOT 1
- 嗨 你他娘的可真是个天才 HOT 1
- Unable to import go-php library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-php.