I've been trying to learn luabind. One of the documents I've been
reading is this one:
http://www.rasterbar.com/products/luabind/docs.htmlHere is the hello world program:
--- Begin ---
#include <iostream>
#include <luabind/luabind.hpp>
void greet()
{
std::cout << "hello world!\n";
}
extern "C" int init(lua_State* L)
{
using namespace luabind;
open(L);
module(L)
[
def("greet", &greet)
];
return 0;
}
--- End ---
Here is how I compile it into a dll (using mingw in Linux):
i586-mingw32msvc-c++ -c -DBUILD_DLL hello_world.cpp -I/usr/include/lua50
i586-mingw32msvc-c++ -shared -o hello_world.dll hello_world.o -L.
-llua50 -lluabind
I have lua50.dll libluabind.a in the current directory when executing
the above commands.
Now, when I run lua and try to execute the functions in hello world, I
get a strange error message. Here is a log of my session:
--- Begin ---
D:\Shared>lua50.exe
Lua 5.0.3 Copyright (C) 1994-2006 Tecgraf, PUC-Rio
> f = loadlib("hello_world.dll", "init")
> print (f)
function: 002FD6E8
> f()
> greet()
no match for function call 'greet' with the parameters ()
candidates are:
greet()
stack traceback:
[C]: in function `greet'
stdin:1: in main chunk
[C]: ?
>
--- End ---
The same program works fine in Linux. Also, using the above procedure,
I can build a simple, working dll that does not use luabind that I
found here:
http://lua-users.org/wiki/CreatingBinaryExtensionModules .
I can build a C++ dll for lua that does not use luabind. The only thing
that is giving me trouble is using luabind to export the fuction, and
only on Windows.
Any ideas?
-Brandon
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php_______________________________________________
luabind-user mailing list
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user