## Can someone tell me how to build Lua on Windows?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

### Can someone tell me how to build Lua on Windows?

This is madness, I'm a bit new to the whole scene of large projects with C/C++, I've looked all over and no one can write it, in plain effing english how to compile Lua in Windows.

I got the source from http://www.lua.org, and am stuck. I can't open the makefile with anything, its pissing me the hell off who the shit doesn't include instructions on how to use their product?! "Here's a jetpack, you can figure out how to assemble it though".

Why should I have to spend hours of my time figuring this damn bullshit out, really I'm mad, can someone tell me . I have both VS 2008 and VS 2005.

Edit
I've figured out how to compile a library against lua5.1.lib, however when running it in game, it cannot find the name.
Last edited by Zorbatron on Tue Jul 14, 2009 12:24 am, edited 1 time in total.

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Can someone tell me how to build Lua on Windows?

There is no project file for MSVC++, just for gcc-compatible compilers. So either get one of those (called MingW on Windows) or install Lua for Windows (binaries, yay!)

Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

### Re: Can someone tell me how to build Lua on Windows?

Ugh, who knows why... thanks though.

I guess I don't need to compile lua right now (I mainly wanted to look at how it worked and learn from it). I just need to know how to write a simple module, how to compile it, and how to link it to my lua scripts. I want to start intergrating C/C++ into my project.

Could you please show me how to make the simplest module you can think of and how to compile it, I cannot find out how to do this anywhere........

Edit:
Oh and btw, I can't even figure out how to install mingw, I go to their sourceforge page, and I can't open the zip, winrar says the .tar file is corrupt or damaged. Why did they make this so easy? Its way to easy, needs to be harder.

Obviously building lua is beyond me, I just want to build a module for it please help me.
Last edited by Zorbatron on Mon Jul 13, 2009 6:30 pm, edited 1 time in total.

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Can someone tell me how to build Lua on Windows?

Assuming cpp and set up with the dlls and libs (which can be found at the LuaBinaries page)

C++:

Code: Select all

#include <lua.hpp>
#include <iostream>

int helloworld(lua_State *L)
{
std::cout<<"Hello, world!" <<std::endl;
}

int luaopen_helloworld(lua_State *L)
{
lua_register(L, "hello", helloworld);
}

compile that to helloworld.dll

Lua:

Code: Select all

require "helloworld"
hello()

Everything can be found here: http://www.lua.org/manual/5.1/
Every lua function has to be: int name(lua_State *L)
(where name is the name)
return value is the number of returned values, which can be 'pushed' by functions as lua_pushnumber(L, number) (as described in the manual)
The luaopen_<name> has to have the same name as the dll, it uses that in require, if you want to skip require you can use package.loadlib(<path to dll>, <function name>) to return the function to you.

Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

### Re: Can someone tell me how to build Lua on Windows?

Thank you dude, you're my new best friend, I will try this and get back to you with the results.

Quick question, which download should I choose? This one (Visual C++ 2005 Compatible) lua5_1_4_Win64_dll8_lib.zip? (I'm running 64)

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Can someone tell me how to build Lua on Windows?

If you want to compile to 64-bit dlls, yes, if you don't choose the x86 one.

Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

### Re: Can someone tell me how to build Lua on Windows?

Alright, I've put the compiled lua dlls into my C:/lua folder, when I go to compile the code I get:

Code: Select all

1>c:\users\-------\documents\visual studio 2005\projects\dlltest\dlltest\dlltest.cpp(1) : fatal error C1083: Cannot open include file: 'lua.hpp': No such file or directory

How do I make the #include preprocessor search in my C:/lua folder?

Edit
Well, I fixed that error by copying the dlls and all the headers files in lua/includes to my project directory then added them to the project, and used #include "lua.hpp" instead of #include <lua.hpp>, however now I get this vauge error.

Code: Select all

1>testdll.obj : error LNK2019: unresolved external symbol _lua_setfield referenced in function "int __cdecl luaopen_helloworld(struct lua_State *)" ([email protected]@[email protected]@@Z)
1>testdll.obj : error LNK2019: unresolved external symbol _lua_pushcclosure referenced in function "int __cdecl luaopen_helloworld(struct lua_State *)" ([email protected]@[email protected]@@Z)


bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Can someone tell me how to build Lua on Windows?

It's been a while since I've done that, all I know is that you need to open your project settings (or global settings if you want this for every project) there is a tab called "Libraries" (or similar, it's been a while) and "Includes", add the path in both of those.

Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

### Re: Can someone tell me how to build Lua on Windows?

Alright thanks, set that up, still getting those two errors though, about an unresolved external link? I'm Building Solution (F7), is this the wrong way?

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: Can someone tell me how to build Lua on Windows?

That means it can't find the libraries, that needs to be setup like I posted.

### Who is online

Users browsing this forum: No registered users and 13 guests