Compiling Lua to Haiku

Hello All;
I trying to compile Lua to Haiku but it fail. I know, already exist a Lua port to Haiku, but I’m trying to put Lua while builds Haiku, to make my custom build, along other softwares, like bash, sed, etc… I wrote a Jamfile to compile it, like this bellow:

SubDir HAIKU_TOP src bin lua src ;

CCFLAGS on lua = -O2 -Wall -c ;

Main lua : lua.c ;

LinkLibraries lua : liblua ;

Library liblua : lapi.c lbaselib.c ldblib.c ldo.c lfunc.c linit.c llex.c lmem.c lobject.c loslib.c lstate.c lstrlib.c ltablib.c lundump.c lzio.c
lauxlib.c lcode.c ldebug.c ldump.c lgc.c liolib.c lmathlib.c loadlib.c lopcodes.c lparser.c lstring.c ltable.c ltm.c lvm.c print.c ;

I put Lua in the directory haiku/src/bin/lua/ , and it compiles well, but when is linking, occurs an error! Bellow, the output:

[root@riemann src]# jam lua
…patience…
…found 1233 target(s)…
…updating 33 target(s)…
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lua.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lapi.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lbaselib.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/ldblib.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/ldo.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lfunc.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/linit.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/llex.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lmem.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lobject.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/loslib.o
In file included from loslib.c:8:
…/…/…/…/headers/posix/errno.h:19: warning: errno' redefined ../../../../headers/build/os/support/Errors.h:403: warning: this is the location of the previous definition Cc ../../../../generated/objects/haiku/x86/release/bin/lua/src/lstate.o Cc ../../../../generated/objects/haiku/x86/release/bin/lua/src/lstrlib.o Cc ../../../../generated/objects/haiku/x86/release/bin/lua/src/ltablib.o Cc ../../../../generated/objects/haiku/x86/release/bin/lua/src/lundump.o Cc ../../../../generated/objects/haiku/x86/release/bin/lua/src/lzio.o Cc ../../../../generated/objects/haiku/x86/release/bin/lua/src/lauxlib.o In file included from lauxlib.c:9: ../../../../headers/posix/errno.h:19: warning:errno’ redefined
…/…/…/…/headers/build/os/support/Errors.h:403: warning: this is the location of the previous definition
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lcode.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/ldebug.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/ldump.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lgc.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/liolib.o
In file included from liolib.c:8:
…/…/…/…/headers/posix/errno.h:19: warning: `errno’ redefined
…/…/…/…/headers/build/os/support/Errors.h:403: warning: this is the location of the previous definition
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lmathlib.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/loadlib.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lopcodes.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lparser.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lstring.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/ltable.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/ltm.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lvm.o
Cc …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/print.o
Archive …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/liblua.a
/tmp/develop/haiku/haiku/generated/cross-tools/bin/i586-pc-haiku-ar: creating …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/liblua.a
Ranlib …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/liblua.a
Link …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lua
/tmp/develop/haiku/haiku/generated/cross-tools/i586-pc-haiku/bin/ld: crti.o: No such file: No such file or directory
collect2: ld returned 1 exit status

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:…/…/…/…/generated/objects/linux/lib ; …/…/…/…/build/scripts/rm_attrs …/…/…/…/generated/objects/linux/x86/release/tools/rm_attrs -f “…/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lua”
/tmp/develop/haiku/haiku/generated/cross-tools/bin/i586-pc-haiku-gcc -lm -o “…/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lua” “…/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lua.o”
“…/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/liblua.a” ;

…failed Link …/…/…/…/generated/objects/haiku/x86/release/bin/lua/src/lua …
…failed updating 1 target(s)…
…updated 32 target(s)…

I don’t know what’s happening, anyone may help!?
Cheers :slight_smile:

You might want to post a message to the haiku mailing list, The devs don’t post on this forum that often. That is if no one else replies first :).

http://www.freelists.org/list/haiku

Actually, this would be more appropriate on the haiku-development mailing list:

http://www.freelists.org/list/haiku-development

no reason to clutter up the general list with development-related questions IMO.

as posted on HaikuPorts, the correct way to make lua on Haiku is to use:
make ansi install INSTALL_TOP=/boot/common LIBS=
be sure to have the LIBS=
on the line, if you don’t it will try to link using -lm which won’t work.
An alternate way to get lua into your builds would be to modify your UserBootScript to load in precompiled packages.
See line 120 in the sample one for an example
http://dev.haiku-os.org/browser/haiku/trunk/build/jam/UserBuildConfig.ReadMe
I’ve loaded mine up from time to time to pull in many packages from a local directory on my ubuntu build PC’s hard drive.
There’s many prebuild binaries now posted on HaikuPorts.

Looks like your compile / linking problem is related to -lm, but also make sure you use the ansi make option, as the posix and/or unix ones had issue building on haiku as i recall.

-scottmc

Are you suggesting to build Lua not using cross-compiling, but inside of Haiku?
At this moment, I’m building a customized distribution of Haiku using UserBuildConfig, adding developer tools to be able to compile software into Haiku! Maybe this works!
– Cheers

Your issue is:
/tmp/develop/haiku/haiku/generated/cross-tools/i586-pc-haiku/bin/ld: crti.o: No such file: No such file or directory

Linker can’t find crti.o to link against.

you need to copy this & the other .o files into one of the folders under i586-pc-haiku. Can’t recall exact folder offhand but should be one with the haiku libraries.

You’ll find the .o files under one of the subfolders in your …/haiku/generated folder.

Ok Nickos!
I’ll do this!

I wasn’t too clear in my last reply. I believe you only need these object files:
init_term_dyn.o
start_dyn.o
crti.o
crtn.o

You’ll find them in:
generated/objects/haiku/x86/release/system/glue & glue/arch/x86

I think placing them in
cross-tools/i586-pc-haiku/lib
should do the trick

OK!
Thanks again!