wrong ELF class: ELFCLASS32

In a recent project, we use OpenResty (Scalable Web Platform by Extending NGINX with Lua) as API gateway. Nginx hosts the webserver, and Lua script stores the logic.

One of our Lua files needs LuaXml modue to parse xml files. But the module is not installed by default in OpenResty. So we get this error when testing the nginx config – nginx: [error] init_by_lua error: /opt/openresty/nginx//conf/errors.lua:1: module ‘LuaXml’ not found.

So I downloaded the module and copy and LuaXml.lua to /opt/openresty/lualib. They are the only two needed files. Try again, then I get a different error:  /opt/openresty/lualib/ wrong ELF class: ELFCLASS32

Google tells me this means the module is for 32 bits OS. Oh, OK. Then I either need to find a module for 64 bits  or compile the source code for 64 bits.

Let’s do the hard way first – compiling LuaXML source code for 64 bits OS. Here is the how to:

mkdir LuaXml
unzip -d LuaXml/

yum install libtermcap-devel ncurses-devel libevent-devel readline-devel

cd LuaXml/
gcc -shared -fPIC -o LuaXML_lib.c -I ../lua-5.1.4/src

Then copy and LuaXml.lua to /opt/openresty/lualib.

The easy way is to use LuaRocks  (Lua package manager):

tar zxpf luarocks-2.3.0.tar.gz
./configure --with-lua-include='/home/ec2-user/app/files/ngx_openresty-'
make bootstrap
luarocks install luaxml

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s