Why can't I use Lua in my app?

Discussion in 'Mac Programming' started by NSDuo, Apr 15, 2009.

  1. macrumors newbie

    Joined:
    Jan 16, 2008
    #1
    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:
    Code:
    "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
    Code:
    "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
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    This may be a silly question, but what architecture(s) did you compile the framework for?
     
  3. thread starter macrumors newbie

    Joined:
    Jan 16, 2008
    #3
    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?
     
  4. macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #4
    Since you're using a Macbook Pro, which uses an Intel processor, you'll want to compile it as an Intel binary. :)
     
  5. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #5
    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
     
  6. thread starter macrumors newbie

    Joined:
    Jan 16, 2008
    #6
    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.
     
  7. thread starter macrumors newbie

    Joined:
    Jan 16, 2008
    #7
    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.
     
  8. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #8
    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
     
  9. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    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.
     
  10. thread starter macrumors newbie

    Joined:
    Jan 16, 2008
    #10
    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?
     
  11. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #11
    Do you have the framework setup properly to be embedded inside your .app so that your app can locate it (@executable_path)?
     
  12. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #12
    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
     
  13. thread starter macrumors newbie

    Joined:
    Jan 16, 2008
    #13
    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.
     

Share This Page