Page 2 of 2

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

Posted: Mon Jul 13, 2009 7:42 pm
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.

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

Posted: Mon Jul 13, 2009 7:54 pm
by bartbes
You have to change the project settings to know it needs to include the lua5.1.lib.

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

Posted: Mon Jul 13, 2009 8:21 pm
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.

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

Posted: Mon Jul 13, 2009 10:51 pm
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?

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

Posted: Tue Jul 14, 2009 6:59 am
by bartbes
Doesn't MSVC++ need a special def file which tells which functions are exported? They needed a specifier anyway.. windows...

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

Posted: Sun Jan 10, 2010 7:51 am
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