🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Need a step by step instruction of insalling lua

Started by
14 comments, last by wizard341 21 years ago
My friend and i have been trying to integrate Lua with visual studio.net and have had no luck. The documentation provided with lua dosnt really explain what to do, and mailing lists dont seem to provide enough feedback, but im sure the great people around here would be able to help. I understand you have to essentially build the library and then include that library in your files... or something like that... but i havent found a clear explanation on how exactly that works. So if anyone would be kind (and experienced) enough to jot down all the steps you need from : Unziping the lua files, to actually being able to call lua functions in a c++ program i would be most greatfull. Thanks!
Advertisement
Sounds like you need to learn how to use Visual Studio before playing with Lua. You obviously don''t understand the basics of building applications using VC++. I suggest you hit Google and learn this before trying to integrate Lua into your app.
---------------------http://www.stodge.net
if you''ll look at the source and license you''ll notice all you have to do is include the source files, so i agree with stodge, RTFM, all you''re doing is compiling and linking more than one source file, not exactly uncommon with projects these days
Thanks for the tastless remark Stodge, however i can assure you i am well competent in creating and including files into Visual Studio. I have tried to put all those .h anc .cpp files into a basic project, create all the lua states in my main file and do a basic lua command, i still get error about external functions not being defined.

Anyways if anyone a bit more knowledgable than Stodge (his solution of course was to relearn what i already know) has any other advice that would be apprechiated.

Might I suggest you post us some error messages? It would be a simple problem like headers using relative paths or some included file (from lua) not being in the correct place.

Perhaps we can solve this!
Thanks for the curtous response Robbo. Probably should have shown what was wrong before hand, oh well.

Anyways, here are the error messages im recieving:

LuaTest2 error LNK2005: _main already defined in Driver.obj
LuaTest2 error LNK2005: _main already defined in Driver.obj
LuaTest2 error LNK2005: _main already defined in Driver.obj
LuaTest2 error LNK2005: _main already defined in Driver.obj
LuaTest2 error LNK2005: _luaX_init already defined in llex.obj
LuaTest2 error LNK2005: _luaY_parser already defined in lparser.obj
LuaTest2 error LNK2005: _main already defined in Driver.obj
LuaTest2 error LNK2001: unresolved external symbol _luaP_opnames
LuaTest2 error LNK2019: unresolved external symbol _WinMain@16 referenced in function _WinMainCRTStartup
LuaTest2 fatal error LNK1120: 2 unresolved externals


I have a basic project with (i am pretty sure) all the .c files that lua came with in the project, along with all the .h files.

I have another file, which is just

#include "lua.h"
#include <iostream.h>
void main()
{
}

So i am not sure whats going on here. Should i be including more files into my file that calls main or am i building the library wrong?
Get the prebuilt libraries and executables here:

http://lua-users.org/wiki/LuaBinaries

Stick 'em somewhere and include the path to the headers in your compiler options

Your main.cpp should be set up like this (the snippet will read and run a lua script)

extern "C"{  #include <lua.h>  #include <lualib.h>  #include <lauxlib.h>}#pragma comment(lib, "lua.lib")#pragma comment(lib, "lualib.lib")#include <iostream>//create a lua statelua_State* g_L = lua_open();main(){    if (int error = lua_dofile(g_L, "YOURLUASCRIPTFILNAMEGOESHERE") != 0)  {    std::cout << "\n[C++]: ERROR(" << error << "): Problem with lua script file!\n\n" << std::endl;  }  //tidy up  lua_close(g_L);  return 0;}



My Website: ai-junkie.com | My Book: AI Techniques for Game Programming



[edited by - fup on June 18, 2003 4:47:08 PM]
PS> Anyone know how I can get the source tags to show the friggin spacing in my code?

[edited by - fup on June 18, 2003 4:49:11 PM]
@fup: FAQ you

[ source ] [ /source ]
quote: Original post by wizard341
LuaTest2 error LNK2005: _main already defined in Driver.obj
...etc.

Without knowing what "Driver.obj" is referencing, I''m guessing you just stuck all the files for lua, the lua interpreter, and the lua compiler all in one project and tried to compile it.

I''ll have to agree with stodge: RTFM.

How appropriate. You fight like a cow.

This topic is closed to new replies.

Advertisement