Re: PHP C++ extension on Windows: setting the working directory the same as PHP
| From: | O'Neil Delpratt | Date: | Wed, 02 Apr 2014 13:56:18 +0000 |
| Subject: | Re: PHP C++ extension on Windows: setting the working directory the same as PHP | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-73519@lists.php.net to get a copy of this message | ||
On 2 Apr 2014, at 14:25, Johannes Schlüter <johannes@schlueters.de> wrote:
> On Wed, 2014-04-02 at 14:14 +0100, O'Neil Delpratt wrote:
>> Hi,
>>
>> I am having trouble getting the correct working directory in the C/C++
>> code of my PHP extension. It should be the same as the PHP working
>> directory, but it is not.
> [...]
>> In linux the C function getcwd() does as expected. It is the same as
>> the PHP cwd, but on windows it always uses the “C:\Program Files
>> \Apache software Foundation\Apache2.2”,
>> whereas in my php script the call ‘echo getcwd();’ returns “C:\www
>> \html” as expected.
>
> when using Apache on Windows you are using mod_mpm which is a threaded
> environment. Thus there is one process which might serve multiple
> requests in different threads. Each thread needs (from user perspective)
> its own working directory, thus our thread isolation library, TSRM,
> provides an API for that: VCWD_GETCWD. Please see
> TSRM/tsrm_virtual_cwd.h for more related APIs. Mind: In 5.6 this has
> been moved to Zend/zend_virtual_cwd.h
Thanks for your quick response.
When I compile my code I am now getting the following error:
Error 93 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\SaxonProcessor.obj
insertions in my C Code:
#include “TSRM/tsrm_virtual_cwd.h”
….
char cwd[256];
VCWD_GETCWD(cwd, sizeof(cwd));
...
Any ideas?
-------------------------------
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/