Compiling Lua - create .so files?

痴心易碎 提交于 2019-12-04 06:24:18

Look how Arch Linux does it. You should not touch LUA_ROOT but the rest of the patch is good and relatively simple to understand.

Don't forget to add -fPIC to the CFLAGS too (the Arch package does it here).

The lua team does not include support for shared libraries by default because doing so in a portable manner is not simple. If you get the srpm for lua from CentOS you should be able to find within it the modifications they make to the lua build process to generate the shared objects that they package and ship. CentOS srpm's live on vault.centos.org.

@beigerac's answer works for lua-5.3.0 also. But, it's just compiling the liblua.so.5.3.0 and establishing symlinks inside lua-5.3.0/src. When doing a sudo make install it is not copying the .so files to /usr/local/lib like it probably should. So, I added onto the patch so it copies the .so files into place.

For lua-5.3.0, these patch files worked for me:

Makefile.patch

And, for src/Makefile:

src/Makefile.patch

Copy the patch files to lua-5.3.0/ and lua-5.3.0/src (respectively) and apply the patches like this:

cd lua-5.3.0/
wget https://gist.githubusercontent.com/dcarrith/899047f3a2d603b25a58/raw/7fa41ee5c0113ed721abe979c269afe48472baf5/Makefile.patch -O Makefile.patch --no-check-certificate
patch -l < Makefile.patch
unexpand Makefile > Makefile.unexpanded
mv Makefile.unexpanded Makefile

cd src/
wget https://gist.githubusercontent.com/dcarrith/6095183b8dc60c909779/raw/614d769d5b70b69b5d67cfb618696bfb906e2aca/src.Makefile.patch -O Makefile.patch --no-check-certificate
patch -l < Makefile.patch
unexpand Makefile > Makefile.unexpanded
mv Makefile.unexpanded Makefile

The unexpand lines are to make sure any spaces that may have been put into place with the patch are converted to tabs so the make won't complain with the error missing separator.

No need to patch anything. Just tell make your extra cflags

lua-5.3.5$ make MYCFLAGS="-fPIC" linux
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!