php - 在 win32 c 扩展中使用 php_strtolower

标签 php c php-extension

我正在尝试为win32平台构建一个php扩展,在php源代码中我找到了一个我想使用的函数php_strtolower(char *, unsigned int length),但是当我尝试调用它时, Visual Studio 提示缺少符号。

Creating library C:\projects\php_mt4_ext\Debug\php_mt4_ext_debug.lib and object C:\projects\php_mt4_ext\Debug\php_mt4_ext_debug.exp Manager.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) char * __cdecl php_strtolower(char *,unsigned int)" (__imp_?php_strtolower@@YAPADPADI@Z) referenced in function "struct _zval_struct * __cdecl GET_MANAGER_ERROR(struct manager_object *,void * * *,class std::basic_string,class std::allocator >,int)" (?GET_MANAGER_ERROR@@YAPAU_zval_struct@@PAUmanager_object@@PAPAPAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) C:\projects\php_mt4_ext\Debug\php_mt4_ext_debug.dll : fatal error LNK1120: 1 unresolved externals

我正在做的代码非常简单,如下

php_printf(php_strtolower("hello",strlen("hello")));

我正在导入 php5ts.lib,所有其他 php 函数似乎都没有任何问题,但这些函数却有问题。

有人知道我是否需要采取任何特殊技巧才能使用这些功能吗?

最佳答案

问题是我包含了并且我的项目是c++ 代码库。

例如,我需要将 php header 包装在 extern“C”中

extern "C" {    
    #include <php.h>    
    #include <info.h>   
    #include<zend_exceptions.h>     
    #include <zend_interfaces.h>    
    #include <ext/standard/php_string.h>
}

然后编译没有任何问题

关于php - 在 win32 c 扩展中使用 php_strtolower,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37895632/

相关文章:

c - 相同的源代码,但不同操作系统上的结果不同

c - 可以用来转换算法的其他数学运算符有哪些

php - 无法执行简单的 Hello World PHP 扩展

javascript - 如何在不编写这么多代码的情况下为多个 jQuery 操作创建一个函数?

javascript - 使用来自 PHP 的数据在按钮单击时添加输入字段

javascript - 无法强制 Web 服务器从磁盘重新加载图像

java - 将 jlong​​ 与 unsigned long int 进行转换

php - 错误 : Class 'SplEnum' not found in PHP 7

php - php-src c 文件最后的注释是什么意思?

PHP - 为什么要实现 HTTP 消息?