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
Before you make a thread asking for help, read this.
User avatar
Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

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

Post by Zorbatron »

bartbes wrote:That means it can't find the libraries, that needs to be setup like I posted.
It is set up correctly.

I have Include files set to C:\lua and C:\lua\include
I have Library files set to C:\lua and C:\lua\include

I think its a linkage problem.
User avatar
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?

Post by bartbes »

You have to change the project settings to know it needs to include the lua5.1.lib.
User avatar
Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

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

Post by Zorbatron »

Man, I hate this stuff...

I right clicked the project, went to configuration properties->Linker->Input and set Additional Dependencies to lua5.1.lib and lua51.lib.

Then I went to Linker->General and set Additional Library Directories to C:\lua
And did the same for C/C++->General-> Additional Library Directories

The header files are including fine it seems.

Can you try and compile this and tell me your settings?

Edit
I think I've found the solution, alot of people on the web have issues with compiling the lua libs in C and their modules in C++. Turns out you need a lua5.1.lib and dll compiled as C++ if you plan to use it with C++ compiled libraries, I will try this now.

Edit
Turns out all I had to do was recompile it from source, not sure why that worked. If that still doesn't work for you, compile it in C++ by changing all the .c files to .cpp files.
User avatar
Zorbatron
Citizen
Posts: 78
Joined: Wed May 27, 2009 6:58 pm

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

Post by Zorbatron »

I have a new problem...

Heres what I compiled (I compiled it all as cpp btw, tried with c same results):
luatestdll.dll

Code: Select all

#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include <iostream>

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

int luaopen_luatestdll(lua_State *L)
{
    lua_register(L, "hello", luatestdll);
	return 0;
}
And when I require it in game it says:

Code: Select all

error loading module 'luatestdll' from file 'C:\Program Files\LOVE\luatestdll.dll':
	The specified procedure could not be found.


stack traceback:
	[C]: ?
	[C]: in function 'require'
	[string "main.lua"]:1: in main chunk
How can I verify the names got exported correctly?
User avatar
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?

Post by bartbes »

Doesn't MSVC++ need a special def file which tells which functions are exported? They needed a specifier anyway.. windows...
gnatch
Prole
Posts: 1
Joined: Sun Jan 10, 2010 7:07 am

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

Post by gnatch »

yeah for msvc you have to add a def file to your project,
here's basically what i wrote, and it worked with require "mylib"

Contents of mylib.DEF:

Code: Select all

LIBRARY	"mylib"
EXPORTS
luaopen_mylib
Post Reply

Who is online

Users browsing this forum: No registered users and 89 guests