generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Lua with C

Previous Thread :: Next Thread 
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
23 Oct 2011 11:09 PM
// This is C, by the way. I also had to take of the html tag thingies.
#include stdio.h
#include ​lua.h
#include ​lauxlib.h
#include ​lualib.h

int main (void) {
    lua_State *L;
    L = lua_open();
    return 0;
}

How does that simple code not run with my computer? I get the error:

Undefined symbols for architecture x86_64:
"_luaL_newstate", referenced from:
_main in cc3s8w3w.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

I would ask in Scripting Helpers, but I doubt that most of them know what C is.
Report Abuse
GoldenUrg is not online. GoldenUrg
Joined: 23 Aug 2009
Total Posts: 6428
23 Oct 2011 11:19 PM
Did you link in the actual Lua code?
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
23 Oct 2011 11:22 PM
I don't think so (I've never tried linking Lua with C before). I don't think there is any Lua code. Where would I put it, anyway? In another file in the same directory?
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
24 Oct 2011 12:20 AM
You need to tell the linker to include the actual Lua library, not just include the header in your code. All headers do in C is tell the linker and your source files that a certain function is being used... you still have to include the libraries to tell the linker where to find the implementation of those functions.
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
24 Oct 2011 06:45 PM
How do I do that? Sadly, I'm not very knowledgeable with the stuff underlying C. Would I do this with C code or in the Terminal, etc?
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
24 Oct 2011 06:56 PM
You don't do it in the source file itself. You have to add the command to include the library by adding an extra thing onto the command line you use to compile it, or by using adding it to the IDE's list of libraries to include, so that the IDE knows to add it to the command line for you.
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
24 Oct 2011 06:59 PM
Okay. Which library should I include then?
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
24 Oct 2011 07:12 PM
Well, I compiled with

    gcc -m32 -o output32

and got the error

    Undefined symbols for architecture i386:
    "_luaL_newstate", referenced from:
    _main in cc7rfYWL.o
    ld: symbol(s) not found for architecture i386`

which means the same thing. What sort of extra thing would I add to the command line, anyway?
Report Abuse
popinman322 is not online. popinman322
Joined: 04 Mar 2009
Total Posts: 5184
24 Oct 2011 07:14 PM
You ARE including the lua dlls, right?

~+[Y U NO WORSHIP BLOCCO?]+~
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
24 Oct 2011 07:17 PM
add -llua and -llualib (i think) to the copile options
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
24 Oct 2011 07:47 PM
Thanks myrkos, but now it says that it can't find llualib. When I include just llib, it gives me a different file that says it can't find the symbol. (This is in 64-bit mode, compiling with 32-bit I'm given a message that says I'm ignoring liblua.a.)
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
24 Oct 2011 08:27 PM
Thanks all! I got it to work with:

gcc -I/usr/local/include -L/usr/local/lib -llua ~/path.c

But is there anyway to shorten this (via aliases or something)? I edited my IDE to execute my programs with this as the default, but I was looking for another way to compile it with the Terminal.
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
24 Oct 2011 08:47 PM
"But is there anyway to shorten this (via aliases or something)? I edited my IDE to execute my programs with this as the default, but I was looking for another way to compile it with the Terminal."

That's exactly what a "Makefile" is for, I'm sure you've seen those before in projects. It's pretty tricky to write them, but a good skill to learn at some point.
Report Abuse
Merlin11188 is not online. Merlin11188
Joined: 20 Dec 2007
Total Posts: 4158
24 Oct 2011 08:48 PM
Yes, I have seen them. I really need to make a formal list of "Things I Need to Learn" because I have a lot of items to put on it, including how to make Makefile stuff.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image