lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


As promised, here are my (very brief) notes on building Lua and a
selection of extensions with Mingw. Most were pretty easy to do, once
I worked out the relevant compile commands. In some cases, arranging
the resulting DLLs and supporting lua code into the right directroy
structure can be a bit challenging, but it's not too hard if you look
at a prebuilt binary or puzzle over the Unix makefile.

(Note to package authors - PLEASE include in the documentation,
somewhere prominent, a listing of the expected final directory layout
for any extension more complex than a single .lua file or .dll/.so)

(Note to the Lua community - some sort of standard for package layout
would help package authors and builders a lot!)

Lua itself - the supplied Makefile supports mingw:
    cd src & mingw32-make mingw
A lot of libraries can simply be built in one step. All you do is
    gcc -O2 -I <lua>\include -shared -s -o XXX.dll XXX.c <lua>\lua51.dll
This uses the fact that gcc can link direct against the Lua DLL.
Libraries that work like this include:
    lpeg
    slnunicode
    lascii85
    lbase64
    lbitlib (DLL needs to be called bit.dll, and you need the attached
handwritten config.h)
    lrandom (need both lrandom.c and random.c in the gcc command)
    lmathx
    lpack
    luuid (need luuid.c, wuuid.c and -lrpcrt4 in the gcc command)
    luafilesystem
    rings
Some need a little more:
ldecnumber
    add "decnumber\decNumber.c decNumber\decContext.c -I decnumber" to
the gcc command
lmapm
    download http://www.tc.umn.edu/~ringx004/mapm-4.9.5.tar.gz
    unpack it, gcc -O2 -c all the *.c files, then ar crs mapm.a *.o
    add "mapm.a -I mapm_4.9.5" to the gcc command
lmd5
    download http://userpages.umbc.edu/~mabzug1/cs/md5/md5-c-100.tar.gz
    unpack it, copy md5-c\global.h to md5global.h
    add "md5-c\md5c.c -I md5-c" to the gcc command
luasql
    download http://www.sqlite.org/sqlite-amalgamation-3_5_9.zip
    unpack it
    gcc -O2 -I <lua>\include -s -shared -o sqlite3.dll luasql.c
ls_sqlite3.c sqlite3.c <lua dll>
    gcc -O2 -I <lua>\include -s -shared -o odbc.dll luasql.c ls_odbc.c
-lodbc32 <lua dll>
    (Oracle is similar using the Oracle Instant Client)
md5
    gcc -O2 -I <lua>\include -shared -s -o core.dll md5.c md5lib.c <lua dll>
    gcc -O2 -I <lua>\include -shared -s -o des56.dll ldes56.c des56.c <lua dll>
luasocket
    (the first gcc command is all on one line)
    gcc -O2 -I <lua>\include -s -shared -o socketcore.dll luasocket.c
timeout.c buffer.c io.c
         auxiliar.c options.c inet.c tcp.c udp.c except.c select.c wsocket.c ^
         -lwsock32 <lua dll>
    gcc -O2 -I <lua>\include -s -shared -o mimecore.dll mime.c <lua dll>
luasys
    (all on one line)
    gcc -O2 -I <lua>\include -s -shared -o sys.dll luasys.c
thread\sys_thread.c sock\sys_sock.c
         mem\sys_mem.c event\evq.c event\timeout.c win32\sys_win32.c ^
         -lwsock32 -lwinmm -lws2_32 %DLL
luazip
    get zziplib-0.13.49.tar.bz2 from the zziplib sourceforge site
    download http://www.zlib.net/zlib-1.2.3.tar.gz
    unpack them
      cd zlib-1.2.3
      gcc -O2 -c *.c
      ar crs ..\zlib.a *.o
      cd ..\zziplib-0.13.49\zzip
      gcc -O2 -D_MSC_VER -c -I .. -I ..\..\zlib-1.2.3 *.c
      ar crs ..\..\zzip.a *.o
    now,
    gcc -O2 -I <lua>\include -s -shared -o zip.dll luazip.c zzip.a
zlib.a -I zlib-1.2.3 -I zziplib-0.13.49 <lua dll>
lzlib
    Download zlib and build zlib.a as above
    gcc -O2 -I <lua>\include -s -shared -o zlib.dll lzlib.c -I
zlib-1.2.3 zlib.a <lua dll>
    gcc -O2 -I <lua>\include -s -shared -o gzip.dll lgzip.c -I
zlib-1.2.3 zlib.a <lua dll>
lua-tinycdb
    gcc -O2 -I <lua>\include -s -shared -o cdb.dll *.c -Dfsync(n) <lua dll>

I hope this is of some use to someone. If nothing else, it puts a copy
of my notes on the Internet, as a backup for me :-)

Paul
/* config.h.in.  Generated from configure.ac by autoheader.  */

/* Define to 1 to use Lua's built-in float to integer cast. */
#undef BUILTIN_CAST

/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H

/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H

/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have the <lualib.h> header file. */
#define HAVE_LUALIB_H 1

/* Define to 1 if you have the <lua.h> header file. */
#define HAVE_LUA_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Name of package */
#undef PACKAGE

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

/* Define to the full name of this package. */
#undef PACKAGE_NAME

/* Define to the full name and version of this package. */
#undef PACKAGE_STRING

/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME

/* Define to the version of this package. */
#undef PACKAGE_VERSION

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Version number of package */
#undef VERSION