Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64286 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44008 invoked from network); 15 Dec 2012 10:15:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Dec 2012 10:15:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=mohammad.ghazavi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mohammad.ghazavi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.170 as permitted sender) X-PHP-List-Original-Sender: mohammad.ghazavi@gmail.com X-Host-Fingerprint: 209.85.223.170 mail-ie0-f170.google.com Received: from [209.85.223.170] ([209.85.223.170:64954] helo=mail-ie0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/F3-19100-DCD4CC05 for ; Sat, 15 Dec 2012 05:15:41 -0500 Received: by mail-ie0-f170.google.com with SMTP id k10so7596385iea.29 for ; Sat, 15 Dec 2012 02:15:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=6YUrmiwHa404J2Gea6+l97GXIBsoSF6+S9J3q8mLr/s=; b=P6ff0ZHgMrrE1b+CTx9yzSawNkrMEVualmXIwRqJIqqKyw2A9LSl6QUFfuFxO08SK+ NlDP/a7wDaNyYvoaC1dxI92yW6PStbBDWTF0MtHrQBlC4SZbH+gRP/m48FEYigSq2hzG hvMUTr7FlV4w29tg6L1i0mR2RNrlafS5Sw8ToheZKdFeSBaEE6yMhf9fLKmhe0S3h2MX EkWAuT+HoMni8zgqmfe5nNGGrEdyeT3cJtR5d/WJcyKQuP+LTbqiaNQvYcQQRAnb2tp9 5jF7JVJJZu0zqaH59N/S91RLIZfn3R29bYyyOeKLvNkYO6drcFcWjCCRxTxdq3qYD6Bb iyEw== Received: by 10.50.0.179 with SMTP id 19mr4203156igf.59.1355566538216; Sat, 15 Dec 2012 02:15:38 -0800 (PST) MIME-Version: 1.0 Sender: mohammad.ghazavi@gmail.com Received: by 10.50.156.163 with HTTP; Sat, 15 Dec 2012 02:14:58 -0800 (PST) In-Reply-To: References: Date: Sat, 15 Dec 2012 13:44:58 +0330 X-Google-Sender-Auth: lrmBVRN8MxEdHeuXonkC8PGn9d4 Message-ID: To: Pierre Joye Cc: PHP internals Content-Type: multipart/alternative; boundary=e89a8f502fc0fad63f04d0e16d57 Subject: Re: [PHP-DEV] error when compiling php 5.3.x with vc++ 2008 From: admin@ecdcconference.org (Amir) --e89a8f502fc0fad63f04d0e16d57 Content-Type: text/plain; charset=UTF-8 Here is my source code: /*******worked on php 5.3********/ #define PHP_COMPILER_ID "VC9" #include #include #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" ZEND_FUNCTION(my_function); PHP_FUNCTION(ig_reverseString); PHP_FUNCTION(ig_parseString); PHP_FUNCTION(ig_connect_to_database); PHP_FUNCTION(get_global_server_variable); zend_function_entry ig_functions[] = { ZEND_FE(my_function, NULL) PHP_FE(ig_reverseString, NULL) PHP_FE(ig_parseString, NULL) PHP_FE(ig_connect_to_database, NULL) PHP_FE(get_global_server_variable, NULL) {NULL, NULL, NULL} }; zend_module_entry my_function_module_entry = { STANDARD_MODULE_HEADER, "my_function_License", ig_functions, NULL, NULL, NULL, NULL, NULL, "4.2.29", STANDARD_MODULE_PROPERTIES }; ZEND_GET_MODULE(my_function); ZEND_FUNCTION(my_function) { bool my_functionLicense; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &my_functionLicense) == FAILURE) { E_ERROR; return; } if(my_functionLicense) { php_printf("license is OK!
"); } else { php_printf("an error occure!!! please contact my_function admin
"); } return; } PHP_FUNCTION(ig_reverseString) { char *input = NULL; int argc = ZEND_NUM_ARGS(); int input_len; char* workstr; int index; if(zend_parse_parameters(argc TSRMLS_CC, "s", &input, &input_len) == FAILURE) return; workstr = (char*) emalloc(input_len + 1); memset(workstr, 0, input_len + 1); for(index=0; index < input_len; index++) { workstr[index] = input[input_len - (index + 1)]; } RETVAL_STRING( workstr, 1 ); efree( workstr ); } char* ig_parseString(char* input); char* ig_parseString(char* input) { char* replace = "Im parsed into source code"; char* output; //char* find; int j=0, i=0, k=0, f=0, c=0; int replaceLenght; replaceLenght = strlen(replace); output = (char*) emalloc(strlen(input) + strlen(replace) + 1); memset(output, 0, strlen(input) + strlen(replace) + 1); /*find = (char*) emalloc(strlen(find) + 1); memset(find, 0, strlen(find) + 1);*/ int lenght; lenght = strlen(input) + strlen(replace); for(c; c < lenght; c++){ if(input[i] == '\0') break;//very important line. get 2H of my best time!!!--->[if remove this line, extension fall on unlimited loop on second run] output[j] = input[i]; i++;j++; if(input[i] == '#' && input[++i] == '#') {//k--; for(k; k < replaceLenght; k++) { if(replace[k] == '\0'){ break;//very important } output[j] = replace[k]; j++; //} } k=1; do{ i++; if(input[i] == '\0') break; }while(input[i] != '#'); i++; output[j] = input[i]; j++;i++; } } return output; efree(output); } PHP_FUNCTION(ig_parseString) { char* input; int argc = ZEND_NUM_ARGS(); int input_len; if(zend_parse_parameters(argc TSRMLS_CC, "s", &input, &input_len) == FAILURE) return; if(ZEND_NUM_ARGS() != 1) WRONG_PARAM_COUNT; RETURN_STRING(ig_parseString(input), 1); efree(input); } PHP_FUNCTION(ig_connect_to_database) { zval fname, *args[3], dbLink; zval selectDB, *args_selectDB[1], retval; long selectDB_status; ZVAL_STRING(&fname, "mysql_connect", 0); MAKE_STD_ZVAL(args[0]); ZVAL_STRING(args[0], "localhost", 1); MAKE_STD_ZVAL(args[1]); ZVAL_STRING(args[1], "root", 1); MAKE_STD_ZVAL(args[2]); ZVAL_STRING(args[2], "", 1); if (call_user_function(EG(function_table), NULL, &fname, &dbLink, 3, args TSRMLS_CC) == FAILURE) { RETURN_STRING("fail to connect to database", 1); } else { zval_ptr_dtor(&args[2]); zval_ptr_dtor(&args[1]); zval_ptr_dtor(&args[0]); /****now! I want to select a database on success****/ ZVAL_STRING(&selectDB, "mysql_select_db", 0); MAKE_STD_ZVAL(args_selectDB[0]); ZVAL_STRING(args_selectDB[0], "clickbartarir", 1); if (call_user_function(EG(function_table), NULL, &selectDB, &retval, 1, args_selectDB TSRMLS_CC) == SUCCESS) { /* I successfully selected database */ convert_to_long(&retval); selectDB_status = Z_LVAL(retval); if(selectDB_status == 1) { /****now! I want to exceute query!****/ zval query, *args_query[1], query_resource; ZVAL_STRING(&query, "mysql_query", 0); MAKE_STD_ZVAL(args_query[0]); ZVAL_STRING(args_query[0], "SELECT * FROM memberplans WHERE userID = 3", 1); if (call_user_function(EG(function_table), NULL, &query, &query_resource, 1, args_query TSRMLS_CC) == SUCCESS) { int resource; resource = Z_RESVAL(query_resource); if(resource == 0) { zend_error(E_ERROR, "wrong query!"); } zval_ptr_dtor(&args_query[0]); /****now! query syntax is ok, I will do fetching...****/ zval fetch_query, *args_fetch_query[1], fetch_query_resource; ZVAL_STRING(&fetch_query, "mysql_fetch_assoc", 0); MAKE_STD_ZVAL(args_fetch_query[0]); ZVAL_RESOURCE(args_fetch_query[0], resource); if (call_user_function(EG(function_table), NULL, &fetch_query, &fetch_query_resource, 1, args_fetch_query TSRMLS_CC) == SUCCESS) { *return_value = fetch_query_resource; } } else { zval_ptr_dtor(&args_query[0]); zend_error(E_ERROR, "wrong mysql query!"); } zval_ptr_dtor(&args_query[0]); } else { zend_error(E_ERROR, "failed to select database!"); } zval_ptr_dtor(&args_selectDB[0]); } else { zend_error(E_ERROR, "database problem"); zval_ptr_dtor(&args_selectDB[0]); } } } PHP_FUNCTION(get_global_server_variable) { // This code makes sure $_SERVER has been initialized if (!zend_hash_exists(&EG(symbol_table), "_SERVER", 8)) { zend_auto_global* auto_global; if (zend_hash_find(CG(auto_globals), "_SERVER", 8, (void **)&auto_global) != FAILURE) { auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC); } } // This fetches $_SERVER['PHP_SELF'] zval** arr; char* script_name; if (zend_hash_find(&EG(symbol_table), "_SERVER", 8, (void**)&arr) != FAILURE) { HashTable* ht = Z_ARRVAL_P(*arr); zval** val; if (zend_hash_find(ht, "PHP_SELF", 9, (void**)&val) != FAILURE) { script_name = Z_STRVAL_PP(val); } } } when I removed last two functions, it compiled successfully. my full error: 1>php_my_function.obj : error LNK2001: unresolved external symbol __imp__executor_globals_id 1>php_my_function.obj : error LNK2001: unresolved external symbol __imp__compiler_globals_id 1>C:\Users\user\Documents\Visual Studio 2008\Projects\php_IG\Release\php_my_function.dll : fatal error LNK1120: 2 unresolved externals On Sat, Dec 15, 2012 at 1:33 PM, Pierre Joye wrote: > hi, > > On Sat, Dec 15, 2012 at 10:51 AM, Amir wrote: > > I did it but have error still > > note: I compile none thread safe and got error when using some user > function > > in my c++ code. > > Not sure what you do in your code but this is typically the error > while trying to link/build TS objects while working with a NTS > configuration. > > Does it happen in PHP or in your ext? Please show the full error message. > > Cheers, > -- > Pierre > > @pierrejoye | http://blog.thepimp.net | http://www.libgd.org > --e89a8f502fc0fad63f04d0e16d57--