Doug,
I communicated with Randy yesterday regarding this issue, and I told him the wrong
answer. Now, after removing all the EXPORT
macros from the code and adding a sample .def file, both mod_perl and libapreq build
okay. After some perusing in MSDN, I found this
paragraph:
Using __declspec(dllimport) is optional on function declarations,
but the compiler produces more efficient code if you use this
keyword. However, you must use __declspec(dllimport) in order
for the importing executable to access the DLL�s public data
symbols and objects. Note that the users of your DLL still need to
link with an import library.
So declaring dllimport is optional on functions but mandatory on variables. I don't
know how much additional efficiency you get by
telling the compiler about the functions being imported, but the code definitely looks
cleaner when you don't clutter it with the
dllexport/dllimport macros.
Sorry for causing confusion in the first place. To summarize, the only mod_perl
change you need for libapreq to work on Win32 is
rebuilding the mod_perl DLL with a .DEF file that exports these 3 functions:
perl_request_rec(), mod_perl_tie_table(), and
sv2request_rec().
-Jiho
Doug MacEachern wrote:
> On Thu, 28 Sep 2000, Jiho Hahm wrote:
>
> > [omitted previous messages]
> >
> > Yep, by defining MODPERL_EXPORTS in every .c file that gets compiled into mod_perl,
> > those .c files will see the MODPERL_API_EXPORT functions as exports (being exported
> > from the binary that the source file will end up in), and all other files that
> > include mod_perl.h will see the functions as external functions to be imported from
> > another DLL.
>
> jiao, (cc-ing [EMAIL PROTECTED], where we should keep this discussion)
> below is the version of your patch which i almost applied, but as randy
> kobes explained to me (and was discussed on this list, but i didn't
> listen close enough :), this can already taken care of by
> including ApacheModulePerl.def, which is part of the current mod_perl cvs
> tree.
>
> Index: src/modules/ApacheModulePerl/ApacheModulePerl.dsp
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/ApacheModulePerl/ApacheModulePerl.dsp,v
> retrieving revision 1.7
> diff -u -r1.7 ApacheModulePerl.dsp
> --- src/modules/ApacheModulePerl/ApacheModulePerl.dsp 2000/09/13 06:06:43 1.7
> +++ src/modules/ApacheModulePerl/ApacheModulePerl.dsp 2000/09/28 21:26:23
> @@ -68,7 +68,7 @@
> # PROP Intermediate_Dir "Debug"
> # PROP Target_Dir ""
> # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D
>"_WINDOWS" /YX /FD /c
> -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D
>"_WINSOCK2API_" /D "_MSWSOCK_" /D "_WINDOWS" /FR /YX /FD /c
> +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D
>"_WINSOCK2API_" /D "_MSWSOCK_" /D "_WINDOWS" /FR /YX /FD /c
> # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
> # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
> # ADD BASE RSC /l 0x409 /d "_DEBUG"
> Index: src/modules/perl/Apache.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
> retrieving revision 1.114
> diff -u -r1.114 Apache.xs
> --- src/modules/perl/Apache.xs 2000/09/28 19:28:33 1.114
> +++ src/modules/perl/Apache.xs 2000/09/28 21:26:24
> @@ -47,6 +47,7 @@
> * ====================================================================
> */
>
> +#define MODPERL_EXPORTS
> #define CORE_PRIVATE
> #include "mod_perl.h"
> #include "mod_perl_xs.h"
> Index: src/modules/perl/Connection.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/Connection.xs,v
> retrieving revision 1.9
> diff -u -r1.9 Connection.xs
> --- src/modules/perl/Connection.xs 2000/04/11 16:38:27 1.9
> +++ src/modules/perl/Connection.xs 2000/09/28 21:26:24
> @@ -1,3 +1,4 @@
> +#define MODPERL_EXPORTS
> #define CORE_PRIVATE
> #include "mod_perl.h"
>
> Index: src/modules/perl/Constants.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/Constants.xs,v
> retrieving revision 1.20
> diff -u -r1.20 Constants.xs
> --- src/modules/perl/Constants.xs 2000/03/30 00:44:40 1.20
> +++ src/modules/perl/Constants.xs 2000/09/28 21:26:24
> @@ -1,3 +1,4 @@
> +#define MODPERL_EXPORTS
> #define CORE_PRIVATE
> #include "mod_perl.h"
>
> Index: src/modules/perl/File.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/File.xs,v
> retrieving revision 1.9
> diff -u -r1.9 File.xs
> --- src/modules/perl/File.xs 1999/06/04 17:50:46 1.9
> +++ src/modules/perl/File.xs 2000/09/28 21:26:25
> @@ -1,4 +1,4 @@
> -
> +#define MODPERL_EXPORTS
> #include "mod_perl.h"
>
> #define ap_fopen(r, name, mode) \
> Index: src/modules/perl/Log.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/Log.xs,v
> retrieving revision 1.11
> diff -u -r1.11 Log.xs
> --- src/modules/perl/Log.xs 2000/03/31 17:07:24 1.11
> +++ src/modules/perl/Log.xs 2000/09/28 21:26:25
> @@ -1,3 +1,4 @@
> +#define MODPERL_EXPORTS
> #include "mod_perl.h"
>
> #if MODULE_MAGIC_NUMBER >= MMN_132
> Index: src/modules/perl/Server.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/Server.xs,v
> retrieving revision 1.7
> diff -u -r1.7 Server.xs
> --- src/modules/perl/Server.xs 2000/09/26 17:34:32 1.7
> +++ src/modules/perl/Server.xs 2000/09/28 21:26:25
> @@ -1,3 +1,4 @@
> +#define MODPERL_EXPORTS
> #define CORE_PRIVATE
> #include "mod_perl.h"
>
> Index: src/modules/perl/Table.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/Table.xs,v
> retrieving revision 1.10
> diff -u -r1.10 Table.xs
> --- src/modules/perl/Table.xs 2000/05/23 15:56:12 1.10
> +++ src/modules/perl/Table.xs 2000/09/28 21:26:25
> @@ -1,3 +1,4 @@
> +#define MODPERL_EXPORTS
> #include "mod_perl.h"
>
> typedef struct {
> Index: src/modules/perl/URI.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/URI.xs,v
> retrieving revision 1.6
> diff -u -r1.6 URI.xs
> --- src/modules/perl/URI.xs 2000/04/10 14:07:07 1.6
> +++ src/modules/perl/URI.xs 2000/09/28 21:26:26
> @@ -1,3 +1,4 @@
> +#define MODPERL_EXPORTS
> #include "mod_perl.h"
> #include "mod_perl_xs.h"
>
> Index: src/modules/perl/Util.xs
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/Util.xs,v
> retrieving revision 1.9
> diff -u -r1.9 Util.xs
> --- src/modules/perl/Util.xs 2000/03/04 20:55:47 1.9
> +++ src/modules/perl/Util.xs 2000/09/28 21:26:26
> @@ -1,3 +1,4 @@
> +#define MODPERL_EXPORTS
> #include "mod_perl.h"
> #include "util_date.h"
>
> Index: src/modules/perl/mod_perl.c
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/mod_perl.c,v
> retrieving revision 1.129
> diff -u -r1.129 mod_perl.c
> --- src/modules/perl/mod_perl.c 2000/09/27 16:13:28 1.129
> +++ src/modules/perl/mod_perl.c 2000/09/28 21:26:35
> @@ -54,6 +54,7 @@
> * And so it was done...
> */
>
> +#define MODPERL_EXPORTS
> #define CORE_PRIVATE
> #include "mod_perl.h"
>
> @@ -1697,7 +1698,7 @@
> return status;
> }
>
> -request_rec *perl_request_rec(request_rec *r)
> +MODPERL_API_EXPORT(request_rec *) perl_request_rec(request_rec *r)
> {
> if(r != NULL) {
> mp_request_rec = (IV)r;
> Index: src/modules/perl/mod_perl.h
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/mod_perl.h,v
> retrieving revision 1.104
> diff -u -r1.104 mod_perl.h
> --- src/modules/perl/mod_perl.h 2000/09/27 23:51:34 1.104
> +++ src/modules/perl/mod_perl.h 2000/09/28 21:26:46
> @@ -71,6 +71,16 @@
> #define SHARED_MODULE
> #endif
>
> +#ifdef WIN32
> +# ifdef MODPERL_EXPORTS
> +# define MODPERL_API_EXPORT(type) __declspec(dllexport) type __stdcall
> +# else
> +# define MODPERL_API_EXPORT(type) __declspec(dllimport) type __stdcall
> +# endif
> +#else
> +# define MODPERL_API_EXPORT(type) type
> +#endif
> +
> #ifdef PERL_THREADS
> #define _INCLUDE_APACHE_FIRST
> #endif
> @@ -1093,6 +1103,10 @@
> void xs_init (void);
> #endif
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> /* mod_perl.c */
>
> /* generic handler stuff */
> @@ -1128,7 +1142,7 @@
> /* per-request gunk */
> int mod_perl_sent_header(request_rec *r, int val);
> int mod_perl_seqno(SV *self, int inc);
> -request_rec *perl_request_rec(request_rec *);
> +MODPERL_API_EXPORT(request_rec *) perl_request_rec(request_rec *);
> void perl_setup_env(request_rec *r);
> SV *perl_bless_request_rec(request_rec *);
> void perl_set_request_rec(request_rec *);
> @@ -1149,7 +1163,7 @@
> void mod_perl_untaint(SV *sv);
> SV *mod_perl_gensym (char *pack);
> SV *mod_perl_slurp_filename(request_rec *r);
> -SV *mod_perl_tie_table(table *t);
> +MODPERL_API_EXPORT(SV *) mod_perl_tie_table(table *t);
> SV *perl_hvrv_magic_obj(SV *rv);
> void perl_tie_hash(HV *hv, char *pclass, SV *sv);
> void perl_util_cleanup(void);
> @@ -1270,7 +1284,7 @@
> pool *perl_get_util_pool(void);
> pool *perl_get_startup_pool(void);
> server_rec *perl_get_startup_server(void);
> -request_rec *sv2request_rec(SV *in, char *pclass, CV *cv);
> +MODPERL_API_EXPORT(request_rec *) sv2request_rec(SV *in, char *pclass, CV *cv);
>
> /* PerlRunXS.xs */
> #define ApachePerlRun_name_with_virtualhost() \
> @@ -1282,6 +1296,10 @@
> #define dOPMask \
> if(!op_mask) Newz(0, op_mask, maxo, char); \
> else Zero(op_mask, maxo, char)
> +
> +#ifdef __cplusplus
> +}
> +#endif
>
> #ifdef PERL_SAFE_STARTUP
>
> Index: src/modules/perl/perl_util.c
> ===================================================================
> RCS file: /home/cvs/modperl/src/modules/perl/perl_util.c,v
> retrieving revision 1.42
> diff -u -r1.42 perl_util.c
> --- src/modules/perl/perl_util.c 2000/09/28 21:00:47 1.42
> +++ src/modules/perl/perl_util.c 2000/09/28 21:26:51
> @@ -47,6 +47,7 @@
> * ====================================================================
> */
>
> +#define MODPERL_EXPORTS
> #include "mod_perl.h"
>
> static HV *mod_perl_endhv = Nullhv;
> @@ -109,7 +110,7 @@
> return mg ? (request_rec *)mg->mg_ptr : NULL;
> }
>
> -request_rec *sv2request_rec(SV *in, char *pclass, CV *cv)
> +MODPERL_API_EXPORT(request_rec *) sv2request_rec(SV *in, char *pclass, CV *cv)
> {
> request_rec *r = NULL;
> SV *sv = Nullsv;
> @@ -223,7 +224,7 @@
> return newRV_noinc(insv);
> }
>
> -SV *mod_perl_tie_table(table *t)
> +MODPERL_API_EXPORT(SV *) mod_perl_tie_table(table *t)
> {
> HV *hv = newHV();
> SV *sv = sv_newmortal();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]