操做系統咱們假定是類 unix
操做系統,採用非源碼文件夾編譯。php
cd ~/ mkdir workspace cd workspace mkdir build-zendapi
您能夠直接 clone
指定的分支,好比 master
分支。到目前爲止 zendAPI
發佈了一個版本 zapi-0.0.2-snapshot
。c++
git clone https://github.com/qcoreteam/zendapi.git zendapidevel git checkout master
若是您的 PHP
安裝在標準路徑,能夠用下面的命令進行編譯git
cd build-zendapi cmake ../zendapidevel
若是您想安裝到特定的路徑,能夠使用下面的命名進行編譯github
cd build-zendapi cmake -DCMAKE_INSTALL_PREFIX=/usr/local/zapi ../zendapidevel
若是您的 PHP
沒有安裝在標準路徑,假定您安裝在 /usr/local/php-7.1.5
目錄下,那麼您能夠使用下面的命令進行編譯segmentfault
cd build-zendapi cmake -DZAPI_OPT_PHP_ROOT_PATH=/usr/local/php-7.1.5 ../zendapidevel
若是您想給編譯器指定額外的選項參數,好比您想用 c++14
標準進行編譯,您能夠使用下面的命令進行編譯api
cd build-zendapi cmake -DCMAKE_CXX_FLAGS="-std=c++14" ../zendapidevel
若是您想使用特定版本的編譯器進行編譯,好比我本身,我本身編譯了 clang 3.5
, 按照路徑爲 /usr/local/llvm-3.5/bin/clang++
,這個路徑沒有在 PATH
環境變量裏面,那麼咱們能夠使用下面的命令進行編譯php7
cd build-zendapi cmake -DCMAKE_C_COMPILER=/usr/local/llvm-3.5/bin/clang \ -DCMAKE_CXX_COMPILER=/usr/local/llvm-3.5/bin/clang++ ../zendapidevel
如今我假定在我本機使用以下命令進行編譯, PHP
安裝在 /usr/local/php7/
, 操做系統爲 MacOS
ide
cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc-6 \ -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-6 -DCMAKE_BUILD_TYPE=Debug ../zendapidevel
若是一切正常的話,您將看到以下的結果ui
-- -------------------------------------------------------------------------------------- -- Thank for using zendAPI project, have a lot of fun! -- -------------------------------------------------------------------------------------- -- ZAPI_VERSION: 0.0.1-devel -- PHP_INCLUDE_PATH: /usr/local/php7/include -- PHP_LIB_PATH: /usr/local/php7/lib/libphp7.dylib -- PHP_EXECUTABLE: /usr/local/php7/bin/php -- PHP_CONFIG_EXECUABLE: /usr/local/php7/bin/php-config -- CMAKE_BUILD_TYPE: Debug -- CMAKE_BINARY_DIR: ~/workspace/build-zendapi -- CMAKE_CURRENT_BINARY_DIR: ~/workspace/build-zendapi -- CMAKE_SOURCE_DIR: ~/workspace/zendapidevel -- PROJECT_BINARY_DIR: ~/workspace/build-zendapi -- PROJECT_SOURCE_DIR: ~/workspace/zendapidevel -- CMAKE_MODULE_PATH: ~/workspace/zendapidevel/cmake/modules -- CMAKE_COMMAND: /usr/local/Cellar/cmake/3.7.2/bin/cmake -- CMAKE_INSTALL_PREFIX: /usr/local -- CMAKE_ROOT: /usr/local/Cellar/cmake/3.7.2/share/cmake -- CMAKE_SYSTEM: Darwin-16.7.0 -- CMAKE_SYSTEM_NAME: Darwin -- CMAKE_SYSTEM_VERSION: 16.7.0 -- CMAKE_SYSTEM_PROCESSOR: x86_64 -- CMAKE_SKIP_RPATH: NO -- CMAKE_VERBOSE_MAKEFILE: FALSE -- CMAKE_CXX_COMPILER: /usr/local/bin/g++-6 -- CMAKE_CXX_COMPILER_VERSION: 6.4.0 -- CMAKE_CXX_FLAGS: -Wa,-q -Wno-macro-redefined -Wno-deprecated-declarations -- CMAKE_AR: /usr/bin/ar -- CMAKE_RANLIB: /usr/bin/ranlib -- -------------------------------------------------------------------------------------- -- Configuring done -- Generating done -- Build files have been written to: ~/workspace/build-zendapi
若是有錯誤,您能夠根據具體的錯誤信息進行排查,若是不能解決,您能夠到咱們的 segmentfault 技術圈進行交流討論 若是沒有錯誤輸入一下命名進行編譯, -j
指定編譯進程數,根據 CPU
線程數定spa
make -j 8
若是整個編譯過程沒有錯誤的話,您將看到以下的輸出,若是有錯誤,麻煩您通知咱們
[100%] Linking CXX shared library ../lib/libzapi.dylib [100%] Built target zapi
最後輸入如下命令進行安裝
make install
安裝完成後您將看到以下輸出
Install the project... -- Install configuration: "Debug" -- Installing: /usr/local/lib/cmake/zendapi/ZendApiConfig.cmake -- Installing: /usr/local/lib/cmake/zendapi/ZendApiConfigVersion.cmake -- Installing: /usr/local/include/zapi -- Installing: /usr/local/include/zapi/CompilerDetection.h -- Installing: /usr/local/include/zapi/ds -- Installing: /usr/local/include/zapi/ds/ArrayItemProxy.h -- Installing: /usr/local/include/zapi/ds/ArrayVariant.h -- Installing: /usr/local/include/zapi/ds/BoolVariant.h -- Installing: /usr/local/include/zapi/ds/CallableVariant.h -- Installing: /usr/local/include/zapi/ds/DoubleVariant.h -- Installing: /usr/local/include/zapi/ds/internal -- Installing: /usr/local/include/zapi/ds/internal/ArrayItemProxyPrivate.h -- Installing: /usr/local/include/zapi/ds/internal/VariantPrivate.h -- Installing: /usr/local/include/zapi/ds/NumericVariant.h -- Installing: /usr/local/include/zapi/ds/ObjectVariant.h -- Installing: /usr/local/include/zapi/ds/StringVariant.h -- Installing: /usr/local/include/zapi/ds/Variant.h -- Installing: /usr/local/include/zapi/Global.h -- Installing: /usr/local/include/zapi/kernel -- Installing: /usr/local/include/zapi/kernel/Exception.h -- Installing: /usr/local/include/zapi/kernel/FatalError.h -- Installing: /usr/local/include/zapi/kernel/Meta.h -- Installing: /usr/local/include/zapi/kernel/NotImplemented.h -- Installing: /usr/local/include/zapi/kernel/OrigException.h -- Installing: /usr/local/include/zapi/kernel/StreamBuffer.h -- Installing: /usr/local/include/zapi/lang -- Installing: /usr/local/include/zapi/lang/Argument.h -- Installing: /usr/local/include/zapi/lang/Class.h -- Installing: /usr/local/include/zapi/lang/Constant.h -- Installing: /usr/local/include/zapi/lang/Extension.h -- Installing: /usr/local/include/zapi/lang/Function.h -- Installing: /usr/local/include/zapi/lang/Ini.h -- Installing: /usr/local/include/zapi/lang/Interface.h -- Installing: /usr/local/include/zapi/lang/internal -- Installing: /usr/local/include/zapi/lang/internal/ExtensionPrivate.h -- Installing: /usr/local/include/zapi/lang/internal/NamespacePrivate.h -- Installing: /usr/local/include/zapi/lang/internal/StdClassPrivate.h -- Installing: /usr/local/include/zapi/lang/Method.h -- Installing: /usr/local/include/zapi/lang/Namespace.h -- Installing: /usr/local/include/zapi/lang/Parameters.h -- Installing: /usr/local/include/zapi/lang/StdClass.h -- Installing: /usr/local/include/zapi/lang/Type.h -- Installing: /usr/local/include/zapi/PhpHeaders.h -- Installing: /usr/local/include/zapi/ProcessorDetection.h -- Installing: /usr/local/include/zapi/protocol -- Installing: /usr/local/include/zapi/protocol/AbstractIterator.h -- Installing: /usr/local/include/zapi/protocol/ArrayAccess.h -- Installing: /usr/local/include/zapi/protocol/Countable.h -- Installing: /usr/local/include/zapi/protocol/Interfaces.h -- Installing: /usr/local/include/zapi/protocol/Serializable.h -- Installing: /usr/local/include/zapi/protocol/Traversable.h -- Installing: /usr/local/include/zapi/stdext -- Installing: /usr/local/include/zapi/stdext/Functional.h -- Installing: /usr/local/include/zapi/stdext/internal -- Installing: /usr/local/include/zapi/stdext/internal/FunctionalPrivate.h -- Installing: /usr/local/include/zapi/stdext/internal/TuplePrivate.h -- Installing: /usr/local/include/zapi/stdext/Tuple.h -- Installing: /usr/local/include/zapi/stdext/TypeTraits.h -- Installing: /usr/local/include/zapi/SystemDetection.h -- Installing: /usr/local/include/zapi/Typedefs.h -- Installing: /usr/local/include/zapi/utils -- Installing: /usr/local/include/zapi/utils/CommonFuncs.h -- Installing: /usr/local/include/zapi/utils/PhpFuncs.h -- Installing: /usr/local/include/zapi/Version.h.in -- Installing: /usr/local/include/zapi/vm -- Installing: /usr/local/include/zapi/vm/AbstractClass.h -- Installing: /usr/local/include/zapi/vm/AbstractMember.h -- Installing: /usr/local/include/zapi/vm/BoolMember.h -- Installing: /usr/local/include/zapi/vm/Callable.h -- Installing: /usr/local/include/zapi/vm/Closure.h -- Installing: /usr/local/include/zapi/vm/Engine.h -- Installing: /usr/local/include/zapi/vm/ExecStateGuard.h -- Installing: /usr/local/include/zapi/vm/FloatMember.h -- Installing: /usr/local/include/zapi/vm/internal -- Installing: /usr/local/include/zapi/vm/internal/AbstractClassPrivate.h -- Installing: /usr/local/include/zapi/vm/internal/AbstractMemberPrivate.h -- Installing: /usr/local/include/zapi/vm/internal/CallablePrivate.h -- Installing: /usr/local/include/zapi/vm/InvokeBridge.h -- Installing: /usr/local/include/zapi/vm/IteratorBridge.h -- Installing: /usr/local/include/zapi/vm/NullMember.h -- Installing: /usr/local/include/zapi/vm/NumericMember.h -- Installing: /usr/local/include/zapi/vm/ObjectBinder.h -- Installing: /usr/local/include/zapi/vm/Property.h -- Installing: /usr/local/include/zapi/vm/StringMember.h -- Installing: /usr/local/include/zapi/vm/ZValMember.h -- Installing: /usr/local/include/zapi/ZendApi.h -- Installing: /usr/local/lib/libzapi.0.0.1.dylib -- Installing: /usr/local/lib/libzapi.0.dylib -- Installing: /usr/local/lib/libzapi.dylib -- Installing: /usr/local/lib/cmake/zendapi/ZendApiTargets.cmake -- Installing: /usr/local/lib/cmake/zendapi/ZendApiTargets-debug.cmake
到此咱們整個安裝過程就結束了, Have a lot of fun。