Compile Recipes

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search

Obtaining and building Lua

https://www.lua.org/ftp/lua-5.2.4.tar.gz


32 bit

Building lua 5.2 manually from source using VC tools:

----------------------------------------
cd src
cl /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
rename lua.obj lua.o
rename luac.obj luac.o
link /DLL /IMPLIB:lua52.lib /OUT:lua52.dll *.obj
link /OUT:lua.exe lua.o lua52.lib
lib /OUT:liblua52.lib *.obj
link /OUT:luac.exe luac.o liblua52.lib
----------------------------------------
prog:       lua.exe
prog:       luac.exe (statically linked)
static lib: lua5.2.-static.lib
importlib:  lua5.2.lib
dll:        lua52.dll
----------------------------------------

VIDEO LINK: http://www.youtube.com/watch?v=X5D_h2X8LCk

Building lua 5.2 using MinGW tools:

----------------------------------------
mingw32-make.exe mingw
----------------------------------------
prog:       lua.exe
prog:       luac.exe (statically linked)
static lib: liblua.a
importlib:  --
dll:        lua52.dll
----------------------------------------

Building lua 5.2 manually from source using MinGW tools:

----------------------------------------
-- build object files
gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_BUILD_AS_DLL  -c  *.c

-- save executable object files for later
rename lua.o lua.obj
rename luac.o luac.obj
-- Build dll with import library from remaining object files
gcc -shared -o lua52.dll -Wl,--out-implib,lua52.a *.o
strip --strip-unneeded lua52.dll
-- build static library
ar rcu liblua52.a *.o
ranlib liblua52.a

-- create luac compiler statically
gcc -o luac.exe luac.obj liblua52.a -lm
-- create lua and dynamically link to dll
gcc -o lua.exe -s  lua.obj lua52.dll -lm
----------------------------------------
prog:       lua.exe
prog:       luac.exe (statically linked)
static lib: liblua52.a
importlib:  lua52.a
dll:        lua52.dll
----------------------------------------

64 bit

https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx
cd \VisualStudio14.0\VC
vcvarsall.bat amd64
cd lua\src\
.. proceed like msvc build above

Installing

/lua/5.2/lua.exe
/lua/5.2/luac.exe
/lua/5.2/lua52.dll
/lua/5.2/lib/liblua52.a, lua5.2.-static.lib or both
/lua/5.2/lib/lua52.a, lua52.lib or both

Obtaining and building Luasocket

git clone https://github.com/diegonehab/luasocket.git

inside luasocked directory:

copy Lua52.props Lua.props
Then open luasocket.sln in Visual Studio
For both subprojects, luasocket and mime:
==> Add the Lua header directory to the includes directory
==> Add the Lua library directory to the library directory
==> Change the output directories and intermediate directories for each to be different
Build
Works in 64 and 32 bit if according Lua import library is supplied.

Obtaining and building LuaXML

http://viremo.eludi.net/LuaXML/LuaXML_130610.zip
git clone https://github.com/LuaDist/luaxml.git
--- Building MSVC CLI Tools (Also works in 64 bit)
cl /MD /O2 /c /IE:\BUILD\src\lua-5.2.4\src -DWIN32 *.c
link /DLL /IMPLIB:LuaXML_lib.lib /OUT:LuaXML_lib.dll *.obj E:\BUILD\src\lua-5.2.4\src\32bit_MSVC\lua52.lib
-- gcc
gcc -O2 -Wall -DWIN32 -I/BUILD/src/lua-5.2.4/src -c  *.c
gcc -shared -o LuaXML_lib.dll -Wl,--out-implib,LuaXML_lib.a *.o E:/BUILD/src/lua-5.2.4/src/32bit_MSVC/lua52.lib 

Obtaining and building OpenSSL

git clone https://github.com/openssl/openssl.git

msvc cli based build - don't forget to get your msvc developer prompt to have all envvars set up properly !
Use git to nail the right stable version (1.1.0). You don't want to build the latest master.
OpenSSL build instructions are pretty straightforward.
read INSTALL file(s) in the openssl root directory.

perl Configure { VC-WIN32 | VC-WIN64A | VC-WIN64I | VC-CE }
nmake
nmake test
nmake install

For 64 bit openssl use the vcvarsall.bat script mentioned above with

vcvarsall.bat amd64

to set up the msvc environment properly. If you want to nmake install have your console elevated to administrator or it will fail.

Obtaining and building Luasec

git clone https://github.com/brunoos/luasec.git

The latest Luasec 0.6 should be compatible with OpenSSl 1.1.0, but it doesn't work. Use 1.0.2 !
After opening the luasec.sln in Visual Studio dependencies to Lua and OpenSSl need to be entered in the project properties (includes and libraries).
In the linker options libssleay32.lib and libeay32.lib must be entered and the "MD" versions removed from additional dependencies.
Use "release" when building, the debug settings are borked.
the additional libraries for the linker also have 32 in their name in the x64 build, same for the winsocket dll.


ADDENDUM: For using OpenSSL 1.1.0 a simple fix should do but does not when using the branch tagged 0.6.
It works with the latest master branch though.
See also: https://github.com/brunoos/luasec/issues/80
Change the additional libraries in the Linker options to point to the new libraries.
libeay(32).dll and ssleay(32).dll are deprecated with this version and replaced by
libcrypto.dll and libssl.dll
Also there is some manual work inside the luasec directory:
From INSTALL:

By default, LuaSec 0.6 includes options for OpenSSL 1.0.2f.
    If you need to generate the options for a different version of OpenSSL:
    $ cd src
    $ lua options.lua -g /usr/include/openssl/ssl.h > options.h


So lets just do that and then bind it to the new OpenSSL. For 32 bit builds:

lua options.lua -g E:\BUILD\src\OpenSSL_1.1.0\OpenSSL_w32\include\openssl\ssl.h > options.h

For 64 bit builds: Change the directories and do (with your path OFC)

lua options.lua -g E:\BUILD\src\OpenSSL_1.1.0\OpenSSL_x64\include\openssl\ssl.h > options.h

Trying this with 0.6 broke the build with a bunch of errors.
Bottom Line: Use latest master branch !!! (as of November 18th, 2016)

Obtaining and building Lua-CJSON

git clone https://github.com/mpx/lua-cjson.git

Compiling ...

gcc -O2 -Wall -DDISABLE_INVALID_NUMBERS -I/BUILD/src/lua-5.2.4/src -c  *.c

Linking ... (MinGW allows lua52.dll directly and doesn't require an import library if lua was built with MinGW - in the example Lua was built with MSVC though.)

gcc -shared -o cjson.dll -Wl,--out-implib,cjson.dll.a lua_cjson.o strbuf.o fpconv.o E:\BUILD\src\lua-5.2.4\src\32bit_MSVC\lua52.lib

Don't forget to adjust your paths!