[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: cross-compile alien
- From: Martin <wtxnh-lua@...>
- Date: Wed, 18 Aug 2010 19:49:30 +0200
On Tue, Aug 17, 2010 at 03:49:09PM +0200, steve donovan wrote:
> Did you use something like this?
>
> if alien.platform == "windows" then
> libc = alien.load("msvcrt.dll")
> else
> libc = alien.default
> end
>
> I remember having to make this edit for Alien to work on LfW with the
> libc example
>
> steve d.
When I changed libc.lua as you suggest it run a little further but it
break at line:
local foo = libc.malloc(string.len("foo") + string.len("bar") + 1)
wine reports an error:
wine: Unhandled page fault on write access to 0x67a81fce at address 0x67a820d9 (thread 0009), starting debugger...
Unhandled exception: page fault on write access to 0x67a81fce in 32-bit code (0x67a820d9).
Register dump:
[ omitted...]
Backtrace show it crash at core.dll module.
> You should use Makefile.win as a base (making the necessary changes to
> work with the GNU tools in your cross-compilation toolchain) instead
> of the regular Makefile. Building libffi for Windows does not use
> configure && make, but uses the patched version of libffi in the win32
> directory directly.
>
> --
> Fabio Mascarenhas
Now I created a Makefile.cross for cross-compilation (included below).
File libffi/win32/win32.c refused to compile (it is customized for
MS compilers I guess) so I used libffi/win32/win32.S file instead.
Than it compiled and linked OK.
But running libc.lua example crashed at the same line with same error
as showed above.
Perhaps my commands for compilation/linking in Makefile are wrong?
Martin
Makefile.cross file:
CFLAGS=-O2 -DWINDOWS -I../installed/include -Ilibffi/win32
LIBFFI_OBJ=libffi/win32/ffi.o libffi/win32/prep_cif.o libffi/win32/types.o libffi/win32/win32.o
CROSS-PREFIX=i586-mingw32msvc-
CC=${CROSS-PREFIX}gcc
AR=${CROSS-PREFIX}ar
RANLIB=${CROSS-PREFIX}ranlib
all: src/alien/core.dll src/alien/struct.dll
libffi/win32/ffi.o: libffi/win32/ffi.c
${CC} $(CFLAGS) -DX86_WIN32 -c -o $@ $<
libffi/win32/prep_cif.o: libffi/win32/prep_cif.c
${CC} $(CFLAGS) -DX86_WIN32 -c -o $@ $<
libffi/win32/types.o: libffi/win32/types.c
${CC} $(CFLAGS) -DX86_WIN32 -c -o $@ $<
libffi/win32/win32.o: libffi/win32/win32.S
${CC} $(CFLAGS) -DX86_WIN32 -c -o $@ $<
libffi/win32/libffi.a: $(LIBFFI_OBJ)
${AR} cru libffi/win32/libffi.a $(LIBFFI_OBJ)
${RANLIB} libffi/win32/libffi.a
src/alien/core.dll: src/alien/core.c libffi/win32/libffi.a
${CC} -shared -s $(CFLAGS) -L../installed -llua51 -o src/alien/core.dll src/alien/core.c libffi/win32/libffi.a
src/alien/struct.dll: src/alien/struct.c
${CC} -shared -s $(CFLAGS) -L../installed -llua51 -o src/alien/struct.dll src/alien/struct.c
install:
mkdir -p ../installed/mods/clua/alien/
cp src/alien/core.dll ../installed/mods/clua/alien/
cp src/alien/struct.dll ../installed/mods/clua/alien/
mkdir -p ../installed/mods/lua/
cp src/alien.lua ../installed/mods/lua/
clean:
rm -f src/alien/*.dll
rm -f libffi/win32/libffi.a
rm -f $(LIBFFI_OBJ)