Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

is it possibile to statically compile modules in apache.exe?

On both linux and mac side I was able to build an apache exec (httpd) stand alone that contains both all deps (apr, apr-util, pcre) and the modules that I needed, but in Windows I was only able to build an apache.exe stand alone (that cointains only apr.dll, apr-util.dll and other deps) without modules. So for example, I cannot be able to use the Order directive in httpd.conf file because the needed module is not included in apache.exe.

I modify a lot of mak files included the httpd.mak file in order to build the apache.exe using link.exe in this way:

link.exe Release\main.obj \ 
Release\httpd.res \ 
srclib\apr\Release\libapr.lib \ 
srclib\pcre\Release\pcre.lib \ 
srclib\apr-iconv\Release\libapriconv.lib \ 
Release\my_modules.lib \ 
Release\libhttpd.lib 

every .lib file has all the obj files built statically with lib.exe

Building in this way the "my_modules.lib" seems to be ignored and all the obj module files were not included in the apache.exe (for example mod_authn_file.obj, mod_expires, mod_actions and so on...).

If I add obj files explicitally during build in this way:

link.exe Release\main.obj \ 
Release\httpd.res \ 
srclib\apr\Release\libapr.lib \ 
srclib\pcre\Release\pcre.lib \ 
srclib\apr-iconv\Release\libapriconv.lib \ 
Release\libhttpd.lib \ 
modules\Release\mod_authn_file.obj \ 
modules\Release\mod_expires.obj \ 
modules\Release\mod_actions.obj \ 
...... (other object modules) 

the size of apache.exe grow but if I use the command apache.exe -M to see Loaded Modules, I find only:

core_module (static) 
win32_module (static) 
mpm_winnt_module (static) 
http:module (static) 
so_module (static) 

[that are all modules that aren't included in my_modules.lib]

Using Dependency Walker I can see all the modules in the apache.exe:

actions_module
alias_module
_ap_get_server_built@0
auth_basic_module
authn_default_module
authn_file_module
authz_default_module
authz_groupfile_module
authz_host_module
authz_user_module
cgi_module
dir_module
expires_module
filter_module
http_module
log_config_module
mime_module
mpm_winnt_module
setenvif_module
so_module
status_module
version_module
win32_module

It seems that the modules were linked but they were not enabled...

I hope that someone can help me.

share|improve this question

1 Answer 1

I've solved it...

I modified modules.c file in os/win32/ folder in this way:

#undef AP_DECLARE_EXPORT
#define AP_DECLARE_STATIC

#define CORE_PRIVATE
#include "httpd.h"
#include "http_config.h"

extern module core_module;
extern module win32_module;
extern module mpm_winnt_module;
extern module http_module;
extern module so_module;
extern module authn_file_module;
extern module authn_default_module;
extern module authz_host_module;
extern module authz_groupfile_module;
extern module authz_user_module;
extern module authz_default_module;
extern module auth_basic_module;
extern module filter_module;
extern module deflate_module;
extern module log_config_module;
extern module expires_module;
extern module setenvif_module;
extern module version_module;
extern module ssl_module;
extern module mime_module;
extern module status_module;
extern module cgi_module;
extern module dir_module;
extern module actions_module;
extern module alias_module;

AP_DECLARE_DATA module *ap_prelinked_modules[] = {
  &core_module,
  &win32_module,
  &mpm_winnt_module,
  &http_module,
  &so_module,
  &authn_file_module,
  &authn_default_module,
  &authz_host_module,
  &authz_groupfile_module,
  &authz_user_module,
  &authz_default_module,
  &auth_basic_module,
  &filter_module,
  &deflate_module,
  &log_config_module,
  &expires_module,
  &setenvif_module,
  &version_module,
  &ssl_module,
  &mime_module,
  &status_module,
  &cgi_module,
  &dir_module,
  &actions_module,
  &alias_module,
  NULL
};

ap_module_symbol_t ap_prelinked_module_symbols[] = {
  {"core_module", &core_module},
  {"win32_module", &win32_module},
  {"mpm_winnt_module", &mpm_winnt_module},
  {"http_module", &http_module},
  {"so_module", &so_module},
  {"authn_file_module", &authn_file_module},
  {"authn_default_module", &authn_default_module},
  {"authz_host_module", &authz_host_module},
  {"authz_groupfile_module", &authz_groupfile_module},
  {"authz_user_module", &authz_user_module},
  {"authz_default_module", &authz_default_module},
  {"auth_basic_module", &auth_basic_module},
  {"filter_module", &filter_module},
  {"deflate_module", &deflate_module},
  {"log_config_module", &log_config_module},
  {"expires_module", &expires_module},
  {"setenvif_module", &setenvif_module},
  {"version_module", &version_module},
  {"ssl_module", &ssl_module},
  {"mime_module", &mime_module},
  {"status_module", &status_module},
  {"cgi_module", &cgi_module},
  {"dir_module", &dir_module},
  {"actions_module", &actions_module},
  {"alias_module", &alias_module},
  {NULL, NULL}
};

AP_DECLARE_DATA module *ap_preloaded_modules[] = {
  &core_module,
  &win32_module,
  &mpm_winnt_module,
  &http_module,
  &so_module,
  &authn_file_module,
  &authn_default_module,
  &authz_host_module,
  &authz_groupfile_module,
  &authz_user_module,
  &authz_default_module,
  &auth_basic_module,
  &filter_module,
  &deflate_module,
  &log_config_module,
  &expires_module,
  &setenvif_module,
  &version_module,
  &ssl_module,
  &mime_module,
  &status_module,
  &cgi_module,
  &dir_module,
  &actions_module,
  &alias_module,
  NULL
};

then I recompile the modules.obj file with this command:

C:\Documents and Settings\sessa\Desktop\httpd-2.2.17-win32-src\httpd-2.2.17_21>
cl.exe /nologo /MT /W3 /Zi /O2 /Oy- /I "./srclib/pcre" /I "./include" /I "./srclib/apr/include" /I "./srclib/apr-util/include" /I "./server/mpm/winnt" /I "./modules/http" /I "./modules/proxy" /I "./modules/mappers" /I "./server" /I"./modules/generators" /I "./modules/filters" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "APR_DECLARE_STATIC" /D "AP_DECLARE_STATIC" /D "API_DECLARE_STATIC" /D"APU_DECLARE_STATIC" /D "PCRE_STATIC" /Fo"Release\\" /Fd"Release\modules_sessa" /FD /c ./os/win32/modules.c

then I rebuild apache.exe and execute apache.exe -M:

Loaded Modules:
 core_module (static)
 win32_module (static)
 mpm_winnt_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (static)
 authn_default_module (static)
 authz_host_module (static)
 authz_groupfile_module (static)
 authz_user_module (static)
 authz_default_module (static)
 auth_basic_module (static)
 filter_module (static)
 log_config_module (static)
 expires_module (static)
 setenvif_module (static)
 version_module (static)
 deflate_module (static)
 ssl_module (static)
 mime_module (static)
 status_module (static)
 cgi_module (static)
 dir_module (static)
 actions_module (static)
 alias_module (static)
Syntax OK

so in this way I have compiled an apache 2.2.17 statically for win32!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.