PDA

View Full Version : Why can't I use Lua in my app?




NSDuo
Apr 15, 2009, 12:28 PM
I really want to use lua for scripting in my game engine. So I downloaded a framework from here: http://blog.trickyfly.com/?p=20 . I compiled the Xcode project to make the framework, included the framework in my project, compiled, and it worked except for this one warning I got:
"warning in /Users/Home/Library/Frameworks/Lua.framework/Lua, file is not of required architecture."
Because of this, when I try to use the library functions I get an error saying
"symbol(s) not found"

I have a feeling that the compiling settings for the framework xcode project don't match what is required by my system. If any one can help me with this, that would be awesome.

On the other hand, if anyone else uses Lua can anyone share their expeiriences setting it up? (I can't use "make" to save my life)

I'm using a Macbook Pro running OS X 5.6



robbieduncan
Apr 15, 2009, 12:31 PM
This may be a silly question, but what architecture(s) did you compile the framework for?

NSDuo
Apr 15, 2009, 12:50 PM
This may be a silly question, but what architecture(s) did you compile the framework for?

When I bring up the info for the project, I see that under "Architectures" it says "ppc i386." I'm very sure that this means it's compiling as a universal binary. Doesn't that mean it should work? Should I compile it as an Intel-only binary?

Littleodie914
Apr 15, 2009, 01:29 PM
Since you're using a Macbook Pro, which uses an Intel processor, you'll want to compile it as an Intel binary. :)

lazydog
Apr 15, 2009, 01:30 PM
Hi

Some time ago I got Lua up and running using Xcode. I recall running into a symbols not found error too. My problem was that I was using the C++ compiler and was #including Lua.h when it should have been Lua.hpp.

b e n

NSDuo
Apr 15, 2009, 02:28 PM
I tried compiling the framework as an Intel-only binary, it didn't work, same warning and error. Maybe I could try a different method of installing lua.

NSDuo
Apr 15, 2009, 08:09 PM
OK, I have a new idea. Would it work if I took the entire lua source, put it into my project and then compiled?

If not maybe anyone out there who has successfully implemented lua into their app could share their experiences setting it up.

lazydog
Apr 16, 2009, 04:11 AM
Hi

Yes, the source will compile as part of your projects without any major problems - that's how integrated Lua initially. If it would help though, I could send you my liblua.a.

b e n

Cromulent
Apr 16, 2009, 05:09 AM
I tried compiling the framework as an Intel-only binary, it didn't work, same warning and error. Maybe I could try a different method of installing lua.

You need to compile your project as Intel only as well. As you posted above you are compiling it for PowerPC and Intel (Universal Binary) which obviously will not work with an Intel only framework.

NSDuo
Apr 16, 2009, 11:29 AM
Hi

Yes, the source will compile as part of your projects without any major problems - that's how integrated Lua initially. If it would help though, I could send you my liblua.a.

b e n

I believe the xcode project also produced a liblua.a. Do I need to include that in my project with the framework? What is its purpose exactly?

kainjow
Apr 16, 2009, 11:57 AM
Do you have the framework setup properly to be embedded inside your .app so that your app can locate it (@executable_path)?

lazydog
Apr 16, 2009, 02:24 PM
I believe the xcode project also produced a liblua.a. Do I need to include that in my project with the framework? What is its purpose exactly?

Ah okay. I'm not exactly sure what's going on in your project but if you link against liblua.a you should be okay. Just drag it into the files and folder view and make sure that the .h (or .hpp) files are accessible. Simplest way is to put the lua source directory into your project directory.


b e n

NSDuo
Apr 16, 2009, 05:55 PM
Well I added all the source files to my project, and...

SUCCESS!!!

All the functions are working, I'm not getting any warnings or errors
Thanks everyone for the help.

For anyone who finds this post via google with the same (or similar) problem, I just want to mention that if you include all of the lua source and compile, you may encounter a duplicate symbol error. Files "lua.c" and "luac.c" both contain "main" functions, be sure to remove these functions if you already have a main function elsewhere in your project.