Re: Unknown reference when trying to access the wrapper DLL

Tristan-37 <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Hi,

when you issue 'bjam' in the examples/hello_word directory it will create a
hello_worldd.dll (notice the second d at the end, it stands for 'debug').
You
can use 'bjam variant=release' to get the non-debug version of the dll, this
file is then called 'hello_world.dll' (now without an additional d). 

Make sure to append the 'd' when using the debug build of your dll!

To load your dll you have to use then
> f,e1,e2 = package.loadlib("hello_worldd.dll", "init") -- notice the
> additional 'd'
This function returns 3 values:
f is a function pointer to the init function or nil on failure. e1 and e2
are
strings with an error message.
> print(f,e1, e2) -- show what happened
When everything worked f is a function and e1 and e2 are nil. Now you can
call
the init function by issuing:
> f() -- this will register the greet method using Luabind.

Note, that 'f,e1,e2 = package.loadlib("hello_worldd.dll", "init")()' is just
the short form of the above steps.

Hint: When you name your init function 'int luaopen_DLLNAME(lua_State* L)'
(replace DLLNAME with the name of your dll) you can use 'require "DLLNAME"'
in
Lua and your init function is automatically executed.



Schala Zeal wrote:
> 
> Well, I compiled a working Lua 5.1.4 -- stripped though, "strip -g
> --strip-unneeded" for the DLL. I have Boost 1.41 headers in the standard
> include directory under the subdirectory 'include/boost', Boost-Build V2
> M12
> present and the BOOST_ROOT set along with LUA_ROOT. BJam compiled it
> successfully with "bjam --toolset=gcc test" and I moved the headers to
> "include/luabind" and the static library (liblua.lib I believe) to my
> MinGW
> lib directory. Though, I had to rename liblua.a (the name the Lua library
> compiled to) to liblua5.1.a because I got errors before then about
> "-llua5.1"
> 
> The examples I simply did "bjam --toolset=gcc" on, but those don't work.
> My
> own projects use "g++ -shared somesourcefile.o -o somelibrary.dll
> -lluabind
> -llua5.1" and deliver the same result.
> 
> On Sat, Jan 2, 2010 at 5:51 AM, Kristoffer Danielsson <
> [email protected]> wrote:
> 
>> Perhaps hello_world.dll is not present or maybe corrupt?
>>
>> ------------------------------
>> Date: Fri, 1 Jan 2010 21:03:33 -0800
>> From: [email protected]
>> To: [email protected]
>> Subject: [luabind] Unknown reference when trying to access the wrapper
>> DLL
>>
>>
>> Hello, I've been having some troubles with Luabind on MinGW, trying to
>> make
>> a test to see if it would work or not. Everything compiles okay... Well,
>> that is... it compiles, at least. Though when I try to use it in Lua 5.1,
>> the following occurs (this happens with provided examples as well)
>>
>> > package.loadlib("hello_world.dll", "init") -- for the record, "init")()
>> results in a "nil value" error
>> > greet()
>> stdin: attempt to call global 'greet' (a nil value)
>> ... etc
>>
>> This is the hello world example provided with Luabind 0.9 RC1. greet() is
>> defined to be in Lua's global namespace, so, I don't know what the heck
>> Lua's interpreter wants. An inputted script produces the same result.
>> Please
>> help. Thank you.
> 

-- 
View this message in context: http://old.nabble.com/Unknown-reference-when-trying-to-access-the-wrapper-DLL-tp26990717p27026594.html
Sent from the Lua C++ Bind mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.