RE: using apxs

2005-02-25 Thread Frédéric Bor
Hi,

You're using C++ classes in C code. That's not possible and you can fix this
either by rewriting your C++ code in C, or either by doing C wrappers (look
for usage of extern C).

Good luck.


-Message d'origine-
De : news [mailto:[EMAIL PROTECTED] De la part de Laszlo
Envoyé : vendredi 25 février 2005 10:15
À : dev@httpd.apache.org
Objet : using apxs

Hi all,

I created a C1.hpp and C1.cpp, compiled and linked into a C1.a
file. I did copy the C1.a file into /usr/local/apache2/lib and
C1.hpp into /usr/local/apache2/include. This class provides
some usefull methods to process a request.

OK. Now I would like to use it in my module mod_xyz.
Entering the command

/usr/local/apache2/bin/apxs -c -i -a mod_xyz.c

returns these lines:

/usr/local/apache2/build/libtool --silent --mode=compile gcc3 -prefer-pic
-DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500
-D_BSD_SOURCE
-D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include
-I/usr/local/apache2/include   -I/usr/local/apache2/include   -c -o
mod_xyz.lo mod_xyz.c  touch
mod_xyz.slo
In file included from mod_xyz.c:4:
/usr/local/apache2/include/C1.hpp:6: parse error before C1
/usr/local/apache2/include/C1.hpp:7: syntax error before '{' token
/usr/local/apache2/include/C1.hpp:20: syntax error before int
/usr/local/apache2/include/C1.hpp:27: syntax error before int
/usr/local/apache2/include/C1.hpp:33: syntax error before int
/usr/local/apache2/include/C1.hpp:39: syntax error before void
/usr/local/apache2/include/C1.hpp:46: syntax error before int
/usr/local/apache2/include/C1.hpp:53: syntax error before char
/usr/local/apache2/include/C1.hpp:55: parse error before ':' token
apxs:Error: Command failed with rc=65536
.

How can I fix it?
-

László Graf





Re: using apxs

2005-02-25 Thread Laszlo
Could you give me an example of a wrapper?
Thank you.
--
László Graf
Frédéric Bor wrote:
Hi,
You're using C++ classes in C code. That's not possible and you can fix this
either by rewriting your C++ code in C, or either by doing C wrappers (look
for usage of extern C).
Good luck.
-Message d'origine-
De : news [mailto:[EMAIL PROTECTED] De la part de Laszlo
Envoyé : vendredi 25 février 2005 10:15
À : dev@httpd.apache.org
Objet : using apxs
Hi all,
I created a C1.hpp and C1.cpp, compiled and linked into a C1.a
file. I did copy the C1.a file into /usr/local/apache2/lib and
C1.hpp into /usr/local/apache2/include. This class provides
some usefull methods to process a request.
OK. Now I would like to use it in my module mod_xyz.
Entering the command
/usr/local/apache2/bin/apxs -c -i -a mod_xyz.c
returns these lines:
/usr/local/apache2/build/libtool --silent --mode=compile gcc3 -prefer-pic
-DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500
-D_BSD_SOURCE
-D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include
-I/usr/local/apache2/include   -I/usr/local/apache2/include   -c -o
mod_xyz.lo mod_xyz.c  touch
mod_xyz.slo
In file included from mod_xyz.c:4:
/usr/local/apache2/include/C1.hpp:6: parse error before C1
/usr/local/apache2/include/C1.hpp:7: syntax error before '{' token
/usr/local/apache2/include/C1.hpp:20: syntax error before int
/usr/local/apache2/include/C1.hpp:27: syntax error before int
/usr/local/apache2/include/C1.hpp:33: syntax error before int
/usr/local/apache2/include/C1.hpp:39: syntax error before void
/usr/local/apache2/include/C1.hpp:46: syntax error before int
/usr/local/apache2/include/C1.hpp:53: syntax error before char
/usr/local/apache2/include/C1.hpp:55: parse error before ':' token
apxs:Error: Command failed with rc=65536
..
How can I fix it?
-
László Graf





RE: using apxs

2005-02-25 Thread Frédéric Bor
In the idea, you have to do something like this:

C1_wrappers.h:

#ifdef __cplusplus
extern C {
#endif

typedef void * C1_OBJECT;
C1_OBJECT C1_create();
void C1_destroy(C1_OBJECT p);
int C1_func_call(C1_OBJECT p, int param1, const char * param2);

#ifdef __cplusplus
}
#endif


C1_wrappers.cpp:

extern C C1_OBJECT C1_create()
{
  return (C1_OBJECT) new C1;
}

extern C void C1_destroy(C1_OBJECT p)
{
  delete (C1*)p;
}

extern C int C1_func_call(C1_OBJECT p, int param1, const char * param2)
{
  return ((C1*)p)-func_call(param1, param2);
}


-Message d'origine-
De : news [mailto:[EMAIL PROTECTED] De la part de Laszlo
Envoyé : vendredi 25 février 2005 10:48
À : dev@httpd.apache.org
Objet : Re: using apxs

Could you give me an example of a wrapper?

Thank you.
--
László Graf






Re: using apxs

2005-02-25 Thread Laszlo
And I suppose that I have to include the C1_wrappers.h
in C1_wrappers.cpp. OK.
After that I also have to compile and link the C1_wrapper.cpp
into a lib file and copy it into /usr/local/apache2/lib.
Right ?
--
László Graf
Frédéric Bor wrote:
In the idea, you have to do something like this:
C1_wrappers.h:
#ifdef __cplusplus
extern C {
#endif
typedef void * C1_OBJECT;
C1_OBJECT C1_create();
void C1_destroy(C1_OBJECT p);
int C1_func_call(C1_OBJECT p, int param1, const char * param2);
#ifdef __cplusplus
}
#endif
C1_wrappers.cpp:
extern C C1_OBJECT C1_create()
{
  return (C1_OBJECT) new C1;
}
extern C void C1_destroy(C1_OBJECT p)
{
  delete (C1*)p;
}
extern C int C1_func_call(C1_OBJECT p, int param1, const char * param2)
{
  return ((C1*)p)-func_call(param1, param2);
}
-Message d'origine-
De : news [mailto:[EMAIL PROTECTED] De la part de Laszlo
Envoyé : vendredi 25 février 2005 10:48
À : dev@httpd.apache.org
Objet : Re: using apxs
Could you give me an example of a wrapper?
Thank you.
--
László Graf