Cannot execute hello world in Windows.

View: New views
2 Messages — Rating Filter:   Alert me  

Cannot execute hello world in Windows.

by Brandon-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.html

Here 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

signature.asc (196 bytes) Download Attachment

Re: Cannot execute hello world in Windows.

by Brandon-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK. I solved the problem. It seems that I was mixing boost versions. To
compile luabind, I was using the headers for boost 1.33.1 that I got
from a project that uses luabind. And then for my program I used my
local Debian boost headers, which are version 1.34.1. I got this sorted
out, and it doesn't matter which I use, as long as I use the same one
each time.

-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

signature.asc (196 bytes) Download Attachment
LightInTheBox - Buy quality products at wholesale price