Re: PHP C++ extension on Windows: setting the working directory the same as PHP

From: Date: Tue, 15 Apr 2014 11:09:01 +0000
Subject: Re: PHP C++ extension on Windows: setting the working directory the same as PHP
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-73697@lists.php.net to get a copy of this message
Dear all, After much struggle I am still getting the following error on windows when I build php with our extension that uses VC_GETCWD: error LNK2001: unresolved external symbol "__declspec(dllimport) char * __cdecl virtual_getcwd(char *,unsigned int,void * * *)" (__imp_?virtual_getcwd@@YAPADPADIPAPAPAX@Z) C:\Users\ond1\Documents\Visual Studio 2012\Projects\saxon\saxon\php_saxon.obj saxon Looking more closely at the linker error it seems that the virtual_getcwd cannot be found where the last argument is void ***. In TSRM/tsrm_virtual_cwd.h we have the following: #ifdef VIRTUAL_DIR #define VCWD_GETCWD(buff, size) virtual_getcwd(buff, size TSRMLS_CC) …. The definition of virtual_getcwd further down in TSRM/tsrm_virtual_cwd.h is as follows. Notice that it uses TSRMLS_DC: CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC); I notice the use of the macro TSRMLS_CC. In TSRM.h we have following: #define TSRMLS_D void ***tsrm_ls #define TSRMLS_DC , TSRMLS_D #define TSRMLS_C tsrm_ls #define TSRMLS_CC , TSRMLS_C It seems that the right macro is not been used or picked up. Any ideas? Thanks and kind regards, O'Neil On 3 Apr 2014, at 13:39, O'Neil Delpratt <oneil@saxonica.com> wrote: > Thanks very much for your help. I will let you know how it goes > On 3 Apr 2014, at 12:55, Anatol Belski <anatol.php@belski.net> wrote: > >> Yes, first of all you need to extern "C" all the PHP headers, as they are >> all C. The php.h is needed on any platform. Then the header include order >> seems odd, please take a look at the following: >> >> >> http://svn.php.net/viewvc/pecl/xmldiff/trunk/php_xmldiff.h?view=markup >> >> http://svn.php.net/viewvc/pecl/ktaglib/trunk/php_ktaglib.h?view=markup >> >> those are the headers of some C++ extensions. Also it might be interesting >> for you to look at their config.w32 . >> >> With the VCWD_GETCWD usage - that's only what you need. It's not necessary >> to use GetCurrentDirectory or getcwd, VCWD_GETCWD will do the job and care >> about TS/NTS portable way. >> >> Please also take a look at this wiki page >> https://wiki.php.net/internals/review_comments with some >> useful hints, >> like that there should be no PHP_FUNCTION definitions in php_myext.h but >> rather in the .cpp file. >> >> Regards >> >> Anatol > > ------------------------------- > O'Neil Delpratt > Software Developer, Saxonica Limited Email: oneil@saxonica.com > Tel: +44 118 946 5894 > Web: http://www.saxonica.com > Saxonica Community site: http://dev.saxonica.com > Bug tracking site: https://saxonica.plan.io/ > > > ------------------------------- O'Neil Delpratt Software Developer, Saxonica Limited Email: oneil@saxonica.com Tel: +44 118 946 5894 Web: http://www.saxonica.com Saxonica Community site: http://dev.saxonica.com Bug tracking site: https://saxonica.plan.io/

« previous php.internals (#73697) next »