nginx with static library

716 views
Skip to first unread message

itspuneet59

unread,
Nov 25, 2014, 11:15:01 PM11/25/14
to openre...@googlegroups.com
Hello,

I am using nginx and willing to link .lua files as library.

I followed Mike's guide for creating a static library

But when I run configure on openresty, it does not work. I have library platform.a in /tmp/files directory
./configure --with-luajit --sbin-path=/usr/sbin --pid-path=/var/run/nginx.pid  -j2 --with-http_stub_status_module --with-ld-opt='-Wl,-E -L/tmp/files -lplatform

Can someone help me in getting this work?

Also, in the config I was using  content_by_lua_file 'abc.lua'
How will that look when I have a static library compiled?

The code in lua file gets changed frequently, is there an option of doing the same with dynamic libraries?

Thanks
Puneet

itspuneet59

unread,
Nov 26, 2014, 10:02:33 AM11/26/14
to openre...@googlegroups.com
Hello,

I am able to link nginx with a static library made up from lua files.
Can somebody please guide me, how can I create a xyz.so for lua code using luajit and make nginx link with that library ?

Thanks and Regards
Puneet

Yichun Zhang (agentzh)

unread,
Nov 26, 2014, 3:12:08 PM11/26/14
to openresty-en
Hello!

On Tue, Nov 25, 2014 at 8:15 PM, itspuneet59 wrote:
> I am using nginx and willing to link .lua files as library.
>
> I followed Mike's guide for creating a static library
> http://stackoverflow.com/questions/11317269/how-to-compile-lua-scripts-into-a-single-executable-while-still-gaining-the-fas
>
> But when I run configure on openresty, it does not work.

Please read the official documentation of ngx_lua on this topic:

https://github.com/openresty/lua-nginx-module#statically-linking-pure-lua-modules

> I have library
> platform.a in /tmp/files directory
> ./configure --with-luajit --sbin-path=/usr/sbin
> --pid-path=/var/run/nginx.pid -j2 --with-http_stub_status_module
> --with-ld-opt='-Wl,-E -L/tmp/files -lplatform
>

Your command is wrong. Please follow the documentation.

Also, try always providing details instead of simply saying "it does
not work", which is not really helpful for diagnostics, unfortunately.

> Also, in the config I was using content_by_lua_file 'abc.lua'
> How will that look when I have a static library compiled?
>

This technique only affects Lua module files that are loaded by
require(). This is also documented in the link above.

> The code in lua file gets changed frequently, is there an option of doing
> the same with dynamic libraries?
>

I don't think LuaJIT supports this. You can ask on the official luajit
mailing list for such features instead.

Regards,
-agentzh

Lord Nynex

unread,
Nov 26, 2014, 5:51:45 PM11/26/14
to openre...@googlegroups.com
agentzh,

I've wondered about this method for awhile now. I've got some things that I'd like to package with the executable but my build suffers from a 'chick or the egg' scenario. In the case of openresty, ./configure builds luajit up front but I need the produced luajit binary to generate bytecode. Unfortunately, this causes a situation where I need to configure openresty twice. This is sub-optimal for build automation.  I have the same issue with luarocks. In my build harness I would like to package luarocks with openresty but there are problems with the interpreter not being present. This causes a lot of manual work. Do you have any advice to overcome this issue?

I was thinking it may be possible to add a secondary script or a switch to configure to only generate the luajit build without configuring openresty. 

I wish there was a Lua equivalent of perl's PAR::Packer (http://search.cpan.org/~rschupp/PAR-Packer-1.024/lib/PAR/Packer.pm) to pull in peripheral dependencies. If I could, I would bundle modules I need that are painful to install. Luasec for example is required for luarocks to pull source from 'https' links but does a terrible job at detecting libssl paths. 

On a side note, I've always wondered why you don't want your nick name capitalized? 


--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yichun Zhang (agentzh)

unread,
Nov 26, 2014, 6:29:22 PM11/26/14
to openresty-en
Hello!

On Wed, Nov 26, 2014 at 2:51 PM, Lord Nynex wrote:
> I was thinking it may be possible to add a secondary script or a switch to
> configure to only generate the luajit build without configuring openresty.
>

Yeah sure. Patches welcome :)

> I wish there was a Lua equivalent of perl's PAR::Packer
> (http://search.cpan.org/~rschupp/PAR-Packer-1.024/lib/PAR/Packer.pm) to pull
> in peripheral dependencies.

Yeah, I was also a PAR::Packer user. We could have something similar
for OpenResty :) Because my time is always limited, you're always
welcome to contribute ideas and even implementations :)

Thanks!
-agentzh
Reply all
Reply to author
Forward
0 new messages