Help with lua

Member
Posts: 194
Joined: 2009.02
Post: #1
I'm trying to get a lua vm running in my project but xcode doesn't seem to properly link all the files or something. I dragged the static lib file, liblua5.1.a and lua.h(and all the other associative headers, lualib.h etc...) to my project, and included the latter header files which should be enough, right?

lua_State* s; compiles fine but lua_State* s = lua_open() returns 1 error, something like:

"_luaL_newtate", refferenced from:
symbol(s) unknown

I checked in lua.h and lua_open is actually a macro defined as:

Code:
#define lua_open()    luaL_newstate()

calling luaL_newstate returns the same errors.


The only difference between trying to compile with or without the lib.a file is a compiler warning which occurs when I try to compile with the lib.a:

-warning in /path/liblua5.1.dylib is not of required architecture

But I didn't include the dylib, I only included the static lib, how is it telling me this? The path referenced leads to a folder of lua lib executable binaries, which is where I originally took the lib.a from. I also checked [targets->link binaries with libs] and the lualib.a file is in fact there.

Any ideas on what's going on?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
you need to build yourself a fat version of lua, and you need to not build the dynamic libraries. My recollection is that the lua config file allows you to do those things easily. If it doesn't, you'll need to build a bunch of thin libs, one for each arch you care about, use lipo to make a fat lib from 'em, and delete the dylibs.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #3
I don't really understand any of what you just said, could I ask you to elaborate a bit?

My understanding was that you include the .a and header files and it should work.
Quote this message in a reply
Member
Posts: 245
Joined: 2005.11
Post: #4
OSC is suggesting, probably correctly, that you have built Lua for only one architecture, rather than as a Universal Binary, while you are building a Universal application.
If your app is universal, then any libraries you use in it also have to be universal or you will get linker errors for one architecture (probably the one you aren't working on).
Try this:
http://soledadpenades.com/2008/05/19/lua...al-binary/
That's how I built my Lua library.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #5
Let me be clear about something, I have no knowledge of building libraries or using the terminal application, so I have no idea what this link is saying http://soledadpenades.com/2008/05/19...versal-binary/, it made no sense to me at all. This is just way beyond my current understanding.

I have tried tried download intel binaries from this site:

http://luabinaries.luaforge.net/download.html
Specifically I downloaded lua5_1_4_Darwin102x86_lib.tar.gz "MacOS X Intel Library and Includes"

Which contained the include header files and also 3 libraries, liblua5.1.a, liblua5.1.dylib, and liblua5.1.so(im assuming this one is also some kind of lib).

Now am I correct in understanding that liblua5.1.a is a static library and that all I should need to do is drag it into my xcode project, along with the header files, and it should work?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
That's an Intel-only binary again, not a universal one.

Time to go out and learn to use the terminal. It's utterly indispensable for development work.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #7
backslash Wrote:OSC is suggesting, probably correctly, that you have built Lua for only one architecture, rather than as a Universal Binary, while you are building a Universal application.
If your app is universal, then any libraries you use in it also have to be universal or you will get linker errors for one architecture (probably the one you aren't working on).
Try this:
http://soledadpenades.com/2008/05/19/lua...al-binary/
That's how I built my Lua library.

Okay, I think I got the make file stuff down, I'm now just getting a "liblua.a file is not of required architecture" compiler warning. So I'm successfully building the libraries now, just not with the correct architecture.

In each makefile their is a PLAT= where you can specify your platform. If I specify plat as macosx_ub can I just use the command 'make local' instead of 'make macosx_ub local' ?

Also in the comment left on the post the guy says to change a few CFLAGS and LDFLAGS in src/MakeFile, did he mean MYCFLAGS and MYLDFLAGS, because a CFLAGS is already used while both MYCFLAGS and MYLDFLAGS are left blank.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #8
Got it running, thanks for all the help.
Quote this message in a reply
Post Reply