By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Problems compiling c++ Extension

P: n/a
Currently I have a PHP extension thats all written and compiles under
windows, but the PC I'm going to end up putting it on is running
Ubuntu 8.04 (g++ 4.2.3).
I've delved into PHP documentation and ended up with a simple
config.m4 file and the process to compile.
However when I try to compile I get loads of errors that I didn't get
when compiling under windows.

I've managed to simplify the code down and create a simple extension
(that compiles on Windows) but still get the same errors (that I don't
really understand) which seem to be caused by php code and not mine,
like:

ext.cpp:20: error: ‘<anonymous>’ has incomplete type
ext.cpp:20: error: invalid use of ‘void.

This was caused by: void ***tsrm_ls.

ext.cpp: In function ‘void zim_ext_class___construct(int, zval*,
zval**, zval*, int)’:
ext.cpp:29: error: expected primary-expression before ‘*’ token
ext.cpp:29: error: expected primary-expression before ‘)’ token
ext.cpp:29: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
ext.cpp:34: error: expected primary-expression before ‘,’ token

Which was caused by: ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThis( ), TSRMLS_C);

I've the source of the simplified code is available at: http://82.45.224.41/test.zip,
and hopefully someone can point me in the right direction.
Aug 30 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
ms***@msn.com wrote:
Currently I have a PHP extension thats all written and compiles under
windows, but the PC I'm going to end up putting it on is running
Ubuntu 8.04 (g++ 4.2.3).
I've delved into PHP documentation and ended up with a simple
config.m4 file and the process to compile.
However when I try to compile I get loads of errors that I didn't get
when compiling under windows.

I've managed to simplify the code down and create a simple extension
(that compiles on Windows) but still get the same errors (that I don't
really understand) which seem to be caused by php code and not mine,
like:

ext.cpp:20: error: ‘<anonymous>’ has incomplete type
ext.cpp:20: error: invalid use of ‘void.

This was caused by: void ***tsrm_ls.

ext.cpp: In function ‘void zim_ext_class___construct(int, zval*,
zval**, zval*, int)’:
ext.cpp:29: error: expected primary-expression before ‘*’ token
ext.cpp:29: error: expected primary-expression before ‘)’ token
ext.cpp:29: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
ext.cpp:34: error: expected primary-expression before ‘,’ token

Which was caused by: ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThis( ), TSRMLS_C);

I've the source of the simplified code is available at: http://82.45.224.41/test.zip,
and hopefully someone can point me in the right direction.
Impossible to say since you didn't include the failing lines and the
ones before and after it. You also didn't have any information on which
files you included.

Sorry - I don't download zip files from unknown sites.

Break it down to a small file which shows the error messages (in this
case it doesn't even need to work at this point) and post the code and
error messages here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 30 '08 #2

P: n/a
On Aug 30, 2:44*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
ms...@msn.com wrote:
Currently I have a PHP extension thats all written and compiles under
windows, but the PC I'm going to end up putting it on is running
Ubuntu 8.04 (g++ 4.2.3).
I've delved into PHP documentation and ended up with a simple
config.m4 file and the process to compile.
However when I try to compile I get loads of errors that I didn't get
when compiling under windows.
I've managed to simplify the code down and create a simple extension
(that compiles on Windows) but still get the same errors (that I don't
really understand) which seem to be caused by php code and not mine,
like:
ext.cpp:20: error: ‘<anonymous>’ has incomplete type
ext.cpp:20: error: invalid use of ‘void.
This was caused by: void ***tsrm_ls.
ext.cpp: In function ‘void zim_ext_class___construct(int, zval*,
zval**, zval*, int)’:
ext.cpp:29: error: expected primary-expression before ‘*’ token
ext.cpp:29: error: expected primary-expression before ‘)’ token
ext.cpp:29: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
ext.cpp:34: error: expected primary-expression before ‘,’ token
Which was caused by: ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThis( ), TSRMLS_C);
I've the source of the simplified code is available at:http://82.45.224..41/test.zip,
and hopefully someone can point me in the right direction.

Impossible to say since you didn't include the failing lines and the
ones before and after it. *You also didn't have any information on which
files you included.

Sorry - I don't download zip files from unknown sites.

Break it down to a small file which shows the error messages (in this
case it doesn't even need to work at this point) and post the code and
error messages here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Sorry first time doing anything in Google groups (was pointed here).
config.m4 file:
---------------------------------------------
PHP_ARG_ENABLE(ext, text ext,
[ --enable-ext Include ext support])

dnl if test "$PHP_EXT" != "no"; then

PHP_REQUIRE_CXX()

dnl Last options tells to use CXX linker
PHP_NEW_EXTENSION(ext, ext.cpp, $ext_shared,,, 1)

dnl fi
---------------------------------------------

ext.cpp file:
---------------------------------------------
/* include standard header */
#include "php.h"
#include "ext/standard/info.h"

#include "zend_compile.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"

#ifdef ZTS
#include "TSRM.h"
#endif

class ext_object
{
public:
zend_object std;
int ii;
} ;

zend_object_value ext_object_new ( zend_class_entry * class_type,
TSRMLS_D );
zend_object_value ext_object_new_ex ( zend_class_entry * class_type,
ext_object ** obj, TSRMLS_D );
void ext_object_free_storage ( void * object, TSRMLS_D );

zend_object_handlers ext_handlers;
zend_class_entry * ext_entry;

ZEND_METHOD(ext_class, __construct)
{
ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThis( ), TSRMLS_C);

long var;

//get parameters
if ( zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
ZEND_NUM_ARGS(), TSRMLS_C, "l", &var) == FAILURE )
{
ZEND_WRONG_PARAM_COUNT();
}

intern->ii = var;

RETURN_TRUE;
}

ZEND_METHOD(ext_class, set)
{
ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThis( ), TSRMLS_C);

long var;

//get parameters
if ( zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
ZEND_NUM_ARGS(), TSRMLS_C, "l", &var) == FAILURE )
{
ZEND_WRONG_PARAM_COUNT();
}

intern->ii = var;

RETURN_TRUE;
}

ZEND_METHOD(ext_class, get)
{
ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThis( ), TSRMLS_C);

RETURN_LONG ( intern->ii );
}

/* compiled function list so Zend knows what's in this module */
zend_function_entry ext_class_functions[] = {
ZEND_ME(ext_class, __construct, NULL, ZEND_ACC_PUBLIC)
ZEND_ME(ext_class, get, NULL, ZEND_ACC_PUBLIC)
ZEND_ME(ext_class, set, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};

PHP_MINIT_FUNCTION(ext)
{
zend_class_entry ce;

memcpy (&ext_handlers, zend_get_std_object_handlers(),
sizeof(zend_object_handlers));
ext_handlers.clone_obj = NULL;

INIT_CLASS_ENTRY(ce, "ext_class", ext_class_functions);
ce.create_object = ext_object_new;
ext_entry = zend_register_internal_class_ex(&ce, NULL, NULL,
TSRMLS_C);

return SUCCESS;
}

/* compiled module information */
zend_module_entry ext_module_entry = {
STANDARD_MODULE_HEADER,
"ext Module",
ext_class_functions,
PHP_MINIT(ext), NULL, NULL, NULL, NULL,
NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
};

/* implement standard "stub" routine to introduce ourselves to Zend */
ZEND_GET_MODULE(ext);

zend_object_value ext_object_new (zend_class_entry * class_type,
TSRMLS_D)
{
ext_object * tmp = NULL;
return ext_object_new_ex (class_type, &tmp, TSRMLS_C);
}

zend_object_value ext_object_new_ex (zend_class_entry * class_type,
ext_object ** obj, TSRMLS_D)
{
zend_object_value retval;
ext_object * intern = NULL;
zval * tmp = NULL;

intern = (ext_object*)emalloc (sizeof (ext_object));
memset (intern, 0, sizeof (ext_object));
intern->std.ce = class_type;

*obj = intern;

ALLOC_HASHTABLE(intern->std.properties);
zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
zend_hash_copy (intern->std.properties, &class_type-
>default_properties,
(copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof (void
*));

retval.handle = zend_objects_store_put (intern,
(zend_objects_store_dtor_t) zend_objects_destroy_object,
(zend_objects_free_object_storage_t) ext_object_free_storage,
NULL, TSRMLS_C);

retval.handlers = &ext_handlers;
return retval;
}

void ext_object_free_storage (void *object, TSRMLS_D)
{
ext_object * intern = (ext_object *) object;
if(!intern) return;

if(intern->std.properties){
zend_hash_destroy(intern->std.properties);
FREE_HASHTABLE(intern->std.properties);
}

// Free our object
efree (object); intern = NULL; object = NULL;
return;
}

---------------------------------------------
The Error I get:

matt@matt-laptop:~/Documents/hi$ make
/bin/bash /home/matt/Documents/hi/libtool --mode=compile g++ -I. -I/
home/matt/Documents/hi -DPHP_ATOM_INC -I/home/matt/Documents/hi/
include -I/home/matt/Documents/hi/main -I/home/matt/Documents/hi -I/
usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/
usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/
date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -
g -O2 -c /home/matt/Documents/hi/ext.cpp -o ext.lo
mkdir .libs
g++ -I. -I/home/matt/Documents/hi -DPHP_ATOM_INC -I/home/matt/
Documents/hi/include -I/home/matt/Documents/hi/main -I/home/matt/
Documents/hi -I/usr/include/php5 -I/usr/include/php5/main -I/usr/
include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/
usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -g -O2 -c /home/matt/Documents/
hi/ext.cpp -fPIC -DPIC -o .libs/ext.o
/home/matt/Documents/hi/ext.cpp:20: error: ‘<anonymous>’ has
incomplete type
/home/matt/Documents/hi/ext.cpp:20: error: invalid use of ‘void’
/home/matt/Documents/hi/ext.cpp:21: error: ‘<anonymous>’ has
incomplete type
/home/matt/Documents/hi/ext.cpp:21: error: invalid use of ‘void’
/home/matt/Documents/hi/ext.cpp:22: error: ‘<anonymous>’ has
incomplete type
/home/matt/Documents/hi/ext.cpp:22: error: invalid use of ‘void’
/home/matt/Documents/hi/ext.cpp: In function ‘void
zim_ext_class___construct(int, zval*, zval**, zval*, int)’:
/home/matt/Documents/hi/ext.cpp:29: error: expected primary-expression
before ‘*’ token
/home/matt/Documents/hi/ext.cpp:29: error: expected primary-expression
before ‘)’ token
/home/matt/Documents/hi/ext.cpp:29: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
/home/matt/Documents/hi/ext.cpp:34: error: expected primary-expression
before ‘,’ token
/home/matt/Documents/hi/ext.cpp: In function ‘void
zim_ext_class_set(int, zval*, zval**, zval*, int)’:
/home/matt/Documents/hi/ext.cpp:46: error: expected primary-expression
before ‘*’ token
/home/matt/Documents/hi/ext.cpp:46: error: expected primary-expression
before ‘)’ token
/home/matt/Documents/hi/ext.cpp:46: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
/home/matt/Documents/hi/ext.cpp:51: error: expected primary-expression
before ‘,’ token
/home/matt/Documents/hi/ext.cpp: In function ‘void
zim_ext_class_get(int, zval*, zval**, zval*, int)’:
/home/matt/Documents/hi/ext.cpp:63: error: expected primary-expression
before ‘*’ token
/home/matt/Documents/hi/ext.cpp:63: error: expected primary-expression
before ‘)’ token
/home/matt/Documents/hi/ext.cpp:63: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
/home/matt/Documents/hi/ext.cpp: At global scope:
/home/matt/Documents/hi/ext.cpp:74: warning: deprecated conversion
from string constant to ‘char*’
/home/matt/Documents/hi/ext.cpp:74: warning: deprecated conversion
from string constant to ‘char*’
/home/matt/Documents/hi/ext.cpp:74: warning: deprecated conversion
from string constant to ‘char*’
/home/matt/Documents/hi/ext.cpp: In function ‘int zm_startup_ext(int,
int)’:
/home/matt/Documents/hi/ext.cpp:84: error: invalid conversion from
‘zend_object_value (*)(zend_class_entry*, <type error>)’ to
‘zend_object_value (*)(zend_class_entry*)’
/home/matt/Documents/hi/ext.cpp:85: error: expected primary-expression
before ‘)’ token
/home/matt/Documents/hi/ext.cpp: At global scope:
/home/matt/Documents/hi/ext.cpp:97: warning: deprecated conversion
from string constant to ‘char*’
/home/matt/Documents/hi/ext.cpp:102: error: ‘<anonymous>’ has
incomplete type
/home/matt/Documents/hi/ext.cpp:102: error: invalid use of ‘void’
/home/matt/Documents/hi/ext.cpp: In function ‘zend_object_value
ext_object_new(zend_class_entry*, <type error>)’:
/home/matt/Documents/hi/ext.cpp:105: error: expected primary-
expression before ‘)’ token
/home/matt/Documents/hi/ext.cpp: At global scope:
/home/matt/Documents/hi/ext.cpp:108: error: ‘<anonymous>’ has
incomplete type
/home/matt/Documents/hi/ext.cpp:108: error: invalid use of ‘void’
/home/matt/Documents/hi/ext.cpp: In function ‘zend_object_value
ext_object_new_ex(zend_class_entry*, ext_object**, <type error>)’:
/home/matt/Documents/hi/ext.cpp:127: error: expected primary-
expression before ‘)’ token
/home/matt/Documents/hi/ext.cpp: At global scope:
/home/matt/Documents/hi/ext.cpp:133: error: ‘<anonymous>’ has
incomplete type
/home/matt/Documents/hi/ext.cpp:133: error: invalid use of ‘void’
make: *** [ext.lo] Error 1

Aug 30 '08 #3

P: n/a
ms***@msn.com wrote:
On Aug 30, 2:44 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>ms...@msn.com wrote:
>>Currently I have a PHP extension thats all written and compiles under
windows, but the PC I'm going to end up putting it on is running
Ubuntu 8.04 (g++ 4.2.3).
I've delved into PHP documentation and ended up with a simple
config.m4 file and the process to compile.
However when I try to compile I get loads of errors that I didn't get
when compiling under windows.
I've managed to simplify the code down and create a simple extension
(that compiles on Windows) but still get the same errors (that I don't
really understand) which seem to be caused by php code and not mine,
like:
ext.cpp:20: error: ‘<anonymous>’ has incomplete type
ext.cpp:20: error: invalid use of ‘void.
This was caused by: void ***tsrm_ls.
ext.cpp: In function ‘void zim_ext_class___construct(int, zval*,
zval**, zval*, int)’:
ext.cpp:29: error: expected primary-expression before ‘*’ token
ext.cpp:29: error: expected primary-expression before ‘)’ token
ext.cpp:29: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
ext.cpp:34: error: expected primary-expression before ‘,’ token
Which was caused by: ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThi s(), TSRMLS_C);
I've the source of the simplified code is available at:http://82.45.224.41/test.zip,
and hopefully someone can point me in the right direction.
Impossible to say since you didn't include the failing lines and the
ones before and after it. You also didn't have any information on which
files you included.

Sorry - I don't download zip files from unknown sites.

Break it down to a small file which shows the error messages (in this
case it doesn't even need to work at this point) and post the code and
error messages here.
Sorry first time doing anything in Google groups (was pointed here).
(150+ lines of code snipped)

As I said - BREAK IT DOWN TO A SMALL FILE... Not 150+ lines of code.
It's typical to post the minimum amount of code necessary to show the
problem. In this case, mainly your include files and declarations.

What version of the g++ compiler are you using? It looks like it may be
an older version.

And BTW - this is not google groups. This is usenet. Google groups is
just a poor interface to usenet. You would be much better accessing
usenet directly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 31 '08 #4

P: n/a
On Aug 31, 2:24*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
ms...@msn.com wrote:
On Aug 30, 2:44 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
ms...@msn.com wrote:
Currently I have a PHP extension thats all written and compiles under
windows, but the PC I'm going to end up putting it on is running
Ubuntu 8.04 (g++ 4.2.3).
I've delved into PHP documentation and ended up with a simple
config.m4 file and the process to compile.
However when I try to compile I get loads of errors that I didn't get
when compiling under windows.
I've managed to simplify the code down and create a simple extension
(that compiles on Windows) but still get the same errors (that I don't
really understand) which seem to be caused by php code and not mine,
like:
ext.cpp:20: error: ‘<anonymous>’ has incomplete type
ext.cpp:20: error: invalid use of ‘void.
This was caused by: void ***tsrm_ls.
ext.cpp: In function ‘void zim_ext_class___construct(int, zval*,
zval**, zval*, int)’:
ext.cpp:29: error: expected primary-expression before ‘*’ token
ext.cpp:29: error: expected primary-expression before ‘)’ token
ext.cpp:29: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
ext.cpp:34: error: expected primary-expression before ‘,’ token
Which was caused by: ext_object * const intern =
(ext_object*)zend_object_store_get_object(getThis (), TSRMLS_C);
I've the source of the simplified code is available at:http://82.45.224.41/test.zip,
and hopefully someone can point me in the right direction.
Impossible to say since you didn't include the failing lines and the
ones before and after it. *You also didn't have any information on which
files you included.
Sorry - I don't download zip files from unknown sites.
Break it down to a small file which shows the error messages (in this
case it doesn't even need to work at this point) and post the code and
error messages here.
Sorry first time doing anything in Google groups (was pointed here).

(150+ lines of code snipped)

As I said - BREAK IT DOWN TO A SMALL FILE... Not 150+ lines of code.
It's typical to post the minimum amount of code necessary to show the
problem. *In this case, mainly your include files and declarations.

What version of the g++ compiler are you using? *It looks like it may be
an older version.

And BTW - this is not google groups. *This is usenet. *Google groups is
just a poor interface to usenet. *You would be much better accessing
usenet directly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Thanks for all your help, but I managed to fix the problem.

For anyone else who comes across this don't change the TSRMLS_DC macro
to ", TSRMLS_D" and the same goes with TSRMLS_CC.

One last question though: What client would you recommend using to
access usenet?

Thanks,
Matthew
Aug 31 '08 #5

P: n/a
Message-ID:
<da**********************************@d45g2000hsc. googlegroups.comfrom
ms***@msn.com contained the following:
>One last question though: What client would you recommend using to
access usenet?
Agent
http://www.forteinc.com/main/homepage.php

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Aug 31 '08 #6

P: n/a
ms***@msn.com wrote:
On Aug 31, 2:24 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>ms...@msn.com wrote:
>>On Aug 30, 2:44 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
ms...@msn.com wrote:
Currently I have a PHP extension thats all written and compiles under
windows, but the PC I'm going to end up putting it on is running
Ubuntu 8.04 (g++ 4.2.3).
I've delved into PHP documentation and ended up with a simple
config.m4 file and the process to compile.
However when I try to compile I get loads of errors that I didn't get
when compiling under windows.
I've managed to simplify the code down and create a simple extension
(that compiles on Windows) but still get the same errors (that I don't
really understand) which seem to be caused by php code and not mine,
like:
ext.cpp:20: error: ‘<anonymous>’ has incomplete type
ext.cpp:20: error: invalid use of ‘void.
This was caused by: void ***tsrm_ls.
ext.cpp: In function ‘void zim_ext_class___construct(int, zval*,
zval**, zval*, int)’:
ext.cpp:29: error: expected primary-expression before ‘*’ token
ext.cpp:29: error: expected primary-expression before ‘)’ token
ext.cpp:29: error: expected ‘,’ or ‘;’ before
‘zend_object_store_get_object’
ext.cpp:34: error: expected primary-expression before ‘,’ token
Which was caused by: ext_object * const intern =
(ext_object*)zend_object_store_get_object(getT his(), TSRMLS_C);
I've the source of the simplified code is available at:http://82.45.224.41/test.zip,
and hopefully someone can point me in the right direction.
Impossible to say since you didn't include the failing lines and the
ones before and after it. You also didn't have any information on which
files you included.
Sorry - I don't download zip files from unknown sites.
Break it down to a small file which shows the error messages (in this
case it doesn't even need to work at this point) and post the code and
error messages here.
Sorry first time doing anything in Google groups (was pointed here).
(150+ lines of code snipped)

As I said - BREAK IT DOWN TO A SMALL FILE... Not 150+ lines of code.
It's typical to post the minimum amount of code necessary to show the
problem. In this case, mainly your include files and declarations.

What version of the g++ compiler are you using? It looks like it may be
an older version.

And BTW - this is not google groups. This is usenet. Google groups is
just a poor interface to usenet. You would be much better accessing
usenet directly.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

Thanks for all your help, but I managed to fix the problem.

For anyone else who comes across this don't change the TSRMLS_DC macro
to ", TSRMLS_D" and the same goes with TSRMLS_CC.

One last question though: What client would you recommend using to
access usenet?

Thanks,
Matthew
Some free options are Thunderbird, Opera, Gravity, Pine, etc. Google
newsreaders.

--
Curtis
Sep 1 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.