Problem Linking to a CPP Extension using VC6

From: Date: Fri, 14 May 2010 15:35:08 +0000
Subject: Problem Linking to a CPP Extension using VC6
Groups: php.internals.win 
Request: Send a blank email to internals-win+get-705@lists.php.net to get a copy of this message
I'm going to be developing a C++ php extension that needs to run under windows. It needs to work with VC6 so it can work with the stock apache binaries. So far, following the steps on http://wiki.php.net/internals/windows/stepbystepbuild, I've been able to compile php with the default extensions and have successfully compiled various extensions from pecl. I've created a basic hello world extension that compiles (and works) without problems when it is a .c file. But if I make it a .cpp file I can no longer compile it because I get a linker error. The error I'm getting is: internal_functions.obj : error LNK2001: unresolved external symbol _sample_module_entry Release_TS\php5ts.dll : fatal error LNK1120: 1 unresolved externals NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\VC98\bin\cl.exe"' : return code '0x2' What do I need to do to compile a c++ extension correctly? Is there something I'm missing in my config.w32 file? I know the config.m4 file needs REQUIRE_CXX(), is there an equivalent in the config.w32? Since the source is really small for my test extension I'm including it at the end of this message. Please let me know what I'm doing wrong or if what I'm doing is possible. I understand that for my test extension that I don't need c++ but for what I want to write I will need c++. Any help will be appreciated. Thanks, ~Jeff Whiting config.w32: ARG_ENABLE("sample", "whether to enable the sample extension", "no"); if (PHP_SAMPLE != "no") { EXTENSION("sample", "php_sample.cpp"); } php_sample.h: #ifndef PHP_SAMPLE_H #define PHP_SAMPLE_H #define PHP_SAMPLE_EXTNAME "sample" #define PHP_SAMPLE_EXTVER "1.0" #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" extern zend_module_entry sample_module_entry; #define phpext_sample_ptr &sample_module_entry #endif php_sample.cpp: #include "php_sample.h" PHP_FUNCTION(sample_hello_world) { php_printf("Hello World!\n"); } static function_entry sample_protocol_functions[] = { PHP_FE(sample_hello_world, NULL) {NULL, NULL, NULL} }; zend_module_entry sample_module_entry = { STANDARD_MODULE_HEADER, PHP_SAMPLE_EXTNAME, sample_protocol_functions, //FUNC NULL, //MINIT NULL, //MSHUT NULL, //RINIT NULL, //RSHUTDOWN NULL, //MINFO PHP_SAMPLE_EXTVER, STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_SAMPLE ZEND_GET_MODULE(sample) #endif

« previous php.internals.win (#705) next »