Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

wizard341

Need a step by step instruction of insalling lua

This topic is 5568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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 state

lua_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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!