PHP-CPP是一个用来开发PHP扩展的C++库,下面引用自官方介绍:
The PHP-CPP library is a C++ library for developing PHP extensions. It offers a collection of well documented and easy-to-use classes that can be used and extended to build native extensions for PHP.
下面记录下开发环境的搭建:
1.安装PHP-CPP
PHP-CPP目前只支持Linux系统和OSX,我这里用的是CentOS 6.0。
git clone https://github.com/CopernicaMarketingSoftware/PHP-CPP.git
cd PHP-CPP
make
如果出现如下错误,说明系统的g++版本过低,不支持c++11.
g++ -Wall -c -g -std=c++11 -fpic -o common/modifiers.o common/modifiers.cpp
cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [common/modifiers.o] Error 1
我系统当前的g++版本信息如下:
g++ --version
g++ (GCC) 4.4.4 20100726 (Red Hat 4.4.4-13)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
我们需要升级以下g++的版本,在CentOS6中可以按下面的方法升级g++:
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
yum --enablerepo testing-1.1-devtools-6 install devtoolset-1.1-gcc-c++
yum install devtoolset-1.1-gcc-c++
scl enable devtoolset-1.1 bash
gcc --version
gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.g++ --version
g++ (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
现在系统已经升级到gcc 4.7.2,g++ 4.7.2版本了,然后继续原先的流程,运行make命令:
make
最后 make install
[root@localhost PHP-CPP]# make install
mkdir -p /usr/include/phpcpp
cp -f phpcpp.h /usr/include
cp -f include/*.h /usr/include/phpcpp
if [ -e libphpcpp.so ]; then cp -f libphpcpp.so /usr/lib; fi
if [ -e libhhvmcpp.so ]; then cp -f libhhvmcpp.so /usr/lib; fi
至此,PHP-CPP安装完成。
开发入门可参考官方文档。
已经有(0)位网友发表了评论,你也评一评吧!
原创文章如转载,请注明:转载自Eddy Blog
原文地址:http://www.rrgod.com/webdesign/898.html 欢迎订阅Eddy Blog。
Tags:PHP-CPP