logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Building & Member Downloads View previous topic :: View next topic
Reply to topic   Topic: Unable to execute Module in Apache using Windows 10
Author
Vinodh



Joined: 22 May 2018
Posts: 3

PostPosted: Tue 22 May '18 11:50    Post subject: Unable to execute Module in Apache using Windows 10 Reply with quote

Hi

Unable to locate the cause of error. Please find the details below .

Environment
Windows 10
Apache 2.4.33 Win32
SO file generated from visual Studio 2017 & its win 32

Error
Can't locate API module structure `cpphello_module' in file C:/Apache24/modules/mod_cpphello.so

httpdconf Code
LoadModule cpphello_module modules/mod_cpphello.so
<Location /hello>
SetHandler helloworld
</Location>

Code in C++
Code:

#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
#include "http_main.h"
#include "util_script.h"
#include "ap_config.h"
#include "http_log.h"

// Apache's compatibility warnings are of no concern to us.
#undef strtoul

// System include files
#include <string>
static int helloworld_handler(request_rec *req)
{
   if (strcmp(req->handler, "helloworld")) {
      return DECLINED;
   }
   if (!req->header_only) {
      ap_rputs("{\"message\": \"Hello world!\"}\n", req);
   }
   req->content_type = "application/json;charset=UTF-8";

   // ap_table_set is too old API
   apr_table_set(req->headers_out, "X-Content-Type-Options", "nosniff");

   return OK;
}

static void helloworld_register_hooks(apr_pool_t *p)
{
   printf("\n ** helloworld_register_hooks  **\n\n");
   ap_hook_handler(helloworld_handler, NULL, NULL, APR_HOOK_MIDDLE);
}

/* Dispatch list for API hooks */
module AP_MODULE_DECLARE_DATA helloworld_module = {
   STANDARD20_MODULE_STUFF,
   NULL, /* create per-dir    config structures */
   NULL, /* merge  per-dir    config structures */
   NULL, /* create per-server config structures */
   NULL, /* merge  per-server config structures */
   NULL, /* table of config file commands       */
   helloworld_register_hooks  /* register hooks */
};
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Tue 22 May '18 15:50    Post subject: Reply with quote

Try;

LoadModule helloworld_module modules/mod_cpphello.so

Why?

/* Dispatch list for API hooks */
module AP_MODULE_DECLARE_DATA helloworld_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-dir config structures */
NULL, /* merge per-dir config structures */
NULL, /* create per-server config structures */
NULL, /* merge per-server config structures */
NULL, /* table of config file commands */
helloworld_register_hooks /* register hooks */
};
Back to top
Vinodh



Joined: 22 May 2018
Posts: 3

PostPosted: Tue 22 May '18 16:15    Post subject: Reply with quote

After Adding below line also its showing the same error .
LoadModule helloworld_module modules/mod_cpphello.so


glsmith wrote:
Try;

LoadModule helloworld_module modules/mod_cpphello.so

Why?

/* Dispatch list for API hooks */
module AP_MODULE_DECLARE_DATA helloworld_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-dir config structures */
NULL, /* merge per-dir config structures */
NULL, /* create per-server config structures */
NULL, /* merge per-server config structures */
NULL, /* table of config file commands */
helloworld_register_hooks /* register hooks */
};
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Tue 22 May '18 23:55    Post subject: Reply with quote

Works for me.
Apache 2.4.33 x86 VC15


https://www.apachehaus.net/temp/helloworld.zip
Back to top
Vinodh



Joined: 22 May 2018
Posts: 3

PostPosted: Wed 23 May '18 11:23    Post subject: Reply with quote

Thanks for your timely help.
I executed in VS cmd prompt and able to compile and run module .

Your so file works for me .
May I know where to use/configure the below command.

set APACHE=C:\Apache24
cl /nologo /O2 /MD /W3 -DWIN32 -D_WIN32 -DMMDB_UINT128_IS_BYTE_ARRAY -I../lib -I%APACHE%\include /c /Fomod_helloworld.obj mod_helloworld.c
link kernel32.lib ws2_32.lib "%APACHE%\lib\libhttpd.lib" "%APACHE%\lib\libapr-1.lib" "%APACHE%\lib\libaprutil-1.lib" /nologo /subsystem:windows /dll /manifest /machine:X86 /out:mod_helloworld.so mod_helloworld.obj
MT -manifest mod_helloworld.so.manifest -outputresource:mod_helloworld.so;2
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Wed 23 May '18 17:29    Post subject: Reply with quote

in the VS2017 x86 Native Tools Command Prompt

Use the ones I put at the bottom of mod_helloworld.c file, the forum here put in line breaks.
Back to top


Reply to topic   Topic: Unable to execute Module in Apache using Windows 10 View previous topic :: View next topic
Post new topic   Forum Index -> Building & Member Downloads