我正在尝试使用c / c ++创建php扩展名。
我已使用修改后的安装方式安装了Visual Studio 2019:
Windows
,并且还下载了php7.1.28源码。
以下是我在C:\php-7.1.28\ext\helloworld\
上的文件
文件:config.w32
ARG_ENABLE("helloworld", "helloworld support", "no");
if (PHP_HELLOWORLD == "yes") {
EXTENSION("helloworld", "php_helloworld.c", true);
}
文件:php_helloworld.h
// we define Module constants
#define PHP_HELLOWORLD_EXTNAME "php_helloworld"
#define PHP_HELLOWORLD_VERSION "0.0.1"
// then we declare the function to be exported
PHP_FUNCTION(helloworld_php);
文件:php_helloworld.c
// include the PHP API itself
#include <php.h>
// then include the header of your extension
#include "php_helloworld.h"
// register our function to the PHP API
// so that PHP knows, which functions are in this module
zend_function_entry helloworld_php_functions[] = {
PHP_FE(helloworld_php, NULL)
{NULL, NULL, NULL}
};
// some pieces of information about our module
zend_module_entry helloworld_php_module_entry = {
STANDARD_MODULE_HEADER,
PHP_HELLOWORLD_EXTNAME,
helloworld_php_functions,
NULL,
NULL,
NULL,
NULL,
NULL,
PHP_HELLOWORLD_VERSION,
STANDARD_MODULE_PROPERTIES
};
// use a macro to output additional C code, to make ext dynamically loadable
ZEND_GET_MODULE(helloworld_php)
// Finally, we implement our "Hello World" function
// this function will be made available to PHP
// and prints to PHP stdout using printf
PHP_FUNCTION(helloworld_php) {
php_printf("Hello World! (from our extension)\n");
}
我想使用php7.1.28
源与编译器MSVC14 (Visual C++ 2015)
进行扩展后,以下日志是我的错误。
C:\php-7.1.28>nmake
Microsoft (R) Program Maintenance Utility Version 14.00.24245.0
Copyright (C) Microsoft Corporation. All rights reserved.
Recreating build dirs
type ext\pcre\php_pcre.def > C:\php-7.1.28\x64\Release_TS\php7ts.dll.def
"" -h win32\ -r C:\php-7.1.28\x64\Release_TS\ -x C:\php-7.1.28\x64\Release_TS\
win32\build\wsyslog.mc
'-h' is not recognized as an internal or external command,
operable program or batch file.
NMAKE : fatal error U1077: '"' : return code '0x1'
Stop.
为什么会出现错误,我该如何解决?
答案 0 :(得分:0)
类似的错误见证了Windows 10 SDK的缺失。在更高版本的PHP中应该有更好的错误消息,其中需要使用mt.exe
和mc.exe
这些工具。
除此之外,我建议使用documented Visual Studio versions和SDK以获得更好的体验。
谢谢