Welcome! Log In Create A New Profile

Advanced

c++ dynamic module fails to load

September 24, 2019 05:05AM
Hi All,

I have a C++ module developed for apache HTTP which now Im trying to port to Nginx. For this I started reading about creating dynamic modules and specifically c++. I already found ngx_cpp_test_module.cpp in the source and able to compile it. I extended it a little and wrote a hello world program which compiles fine but when I restart Nginx I get following error:

[build@8e269df38d20 nginx-1.16.1]$ sudo /usr/sbin/nginx -t
nginx: [emerg] dlopen() "/etc/nginx/modules/ngx_http_cpp_hello_module.so" failed (/etc/nginx/modules/ngx_http_cpp_hello_module.so: undefined symbol: ngx_http_cpp_hello_module) in /etc/nginx/nginx.conf:2

I have configured it as follows:

./configure --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-lstdc++ -lrt -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/home/build --add-dynamic-module=/mnt/src/hello-world-cpp --with-threads

The config:

ngx_addon_name=ngx_http_cpp_hello_module

if test -n "$ngx_module_link"; then
ngx_module_type=HTTP
ngx_module_name=$ngx_addon_name
ngx_module_srcs="$ngx_addon_dir/ngx_http_cpp_hello_world_module.cpp"

. auto/module
else
HTTP_MODULES="$HTTP_MODULES ngx_http_hello_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_cpp_hello_world_module.cpp"
fi

As per the error "undefined symbol: ngx_http_cpp_hello_module" Im trying to understand why it is trying to find that function in the code.
Is there something that I'm missing during configuring or compilation process?
Subject Author Posted

c++ dynamic module fails to load

astre September 24, 2019 05:05AM

Re: c++ dynamic module fails to load

Maxim Dounin September 24, 2019 08:18AM

Re: c++ dynamic module fails to load

astre September 25, 2019 02:13AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 71
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready