Christopher Thomas
Christopher Thomas

Reputation: 4723

using php_strtolower in win32 c extension

I'm trying to build a php extension for the win32 platform, in the php source I've found a function php_strtolower(char *, unsigned int length) that I want to use, but when I attempt to call it, visual studio complains about a missing symbol.

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

the code I'm doing is very simple, it's just as follows

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

I'm importing the php5ts.lib and all the other php functions don't seem to have any problem, but these functions do.

anybody know if there is any special trick I'm supposed to do in order to be able to use these functions?

Upvotes: 0

Views: 58

Answers (1)

Christopher Thomas
Christopher Thomas

Reputation: 4723

the problem was that I was including and my project was a c++ codebase.

So I needed to do wrap the php headers in extern "C", for example

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

then it compiled without any problems

Upvotes: 0

Related Questions