This is a discussion on Help! ERROR LINK 2005 raised when create PHP extension DLL using STL in VC++2005! within the PHP General forums, part of the PHP Programming Forums category; I created a VC++2005 PHP extension DLL project following the link "Creating a PHP 5 Extension with Visual ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I created a VC++2005 PHP extension DLL project following the link
"Creating a PHP 5 Extension with Visual C++ 2005" :http:// blog.slickedit.com/?p=128#comment-161 Compiling and link are OK when just not include STL. But When I included STL header files and used STL object, I got ERROR LINK 2005 as follows. Any one can give me a hint? Thanks. --------------------------------------------------------------------------- ---- Linking... libcpmtd.lib(string.obj) : error LNK2005: "public: void __thiscall std::_Container_base::_Orphan_all(void)const " (? _Orphan_all@_Container_base@std@@QBEXXZ) already defined in AutoClasssify.obj libcpmtd.lib(locale0.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in AutoClasssify.obj libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl operator delete(void *,void *)" (??3@YAXPAX0@Z) already defined in AutoClasssify.obj libcpmtd.lib(locale0.obj) : error LNK2005: "public: void __thiscall std::_Container_base::_Orphan_all(void)const " (? _Orphan_all@_Container_base@std@@QBEXXZ) already defined in AutoClasssify.obj --------------------------------------------------------------------------- -- Here is my source code of file AutoClassify.cpp: #include "zend_config.w32.h" #include "php.h" #include <string> #include <hash_map> using namespace std; using namespace stdext; //ZEND_FUNCTION(DoubleUp); ZEND_FUNCTION(WordSeg); /* compiled function list so Zend knows what's in this module */ zend_function_entry AutoClassifyExtModule_functions[] = { ZEND_FE(WordSeg, NULL) {NULL, NULL, NULL} }; /* compiled module information */ zend_module_entry AutoClassifyExtModule_module_entry = { STANDARD_MODULE_HEADER, "AutoClassify Module", AutoClassifyExtModule_functions, NULL, NULL, NULL, NULL, NULL, NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; /* implement standard "stub" routine to introduce ourselves to Zend */ ZEND_GET_MODULE(AutoClassifyExtModule) ZEND_FUNCTION(WordSeg) { char* pszCorpus; int nStrLen; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &pszCorpus, &nStrLen) == FAILURE) { RETURN_STRING("Bad parameters!", true); } // Careful! Can't use big size stack variable here!!! static char szBuffer[1024*1024]; // 1M byte buffer char* pszBuffer = szBuffer; // // do segment word stuff // hash_map<string, int> hashWords; // // // // just test sprintf(pszBuffer, "Hello from WordSeg function of customized PHP extension module."); RETURN_STRINGL(pszBuffer, strlen(pszBuffer), true); } |
![]() |
| Thread Tools | |
| Display Modes | |
|
|