Re: Loadlib problems
Status: Alpha
Brought to you by:
cwalther
From: Christian W. <cwa...@gm...> - 2008-05-19 18:18:11
|
Andrea Viarengo wrote: > 1) I cannot understand how to link the dll, to access functions defined > in pipmak.exe (like terminalPrintf in your example), so I comment out these. > (but in this moment, access to these functions isn't fundamental for me) It is important insofar as you need access to the Lua interpreter functions that are linked statically into Pipmak.exe, otherwise you need to link in an additional copy of Lua (I suppose that's what you've done, if it works for you). You need to link your plugin with Pipmak.exe.a, which is produced in the compilation of Pipmak with GCC (I don't know how you'd generate it when compiling Pipmak with MSVC, or if that is even possible). I have attached the version corresponding to the 0.2.7 release to this message. You may have to rename it to end in ".lib" for MSVC to recognize it as an import library. > 2) I have successfully compiled you example after commented out call to > terminalPrintf and after added definition > > #define LUA_API __declspec(dllexport) > > and postponing LUA_API to the init definition: > > LUA_API int init(lua_State *L) { > .... > } > > Without these steps I get an "procedure not found" during loadlib > (Probably this is needed only with Windows and/or MSVC) It worked for me with the GCC-cross-compiled version, so apparently GCC exported the function automatically. You could also do it using a .def file, I suppose. > As you can see, I have created a library "tools" > > so these functions are permitted: > > a) tools.greeting() > b) tools.getprojectpath() > c) tools.newgreeter("test") > > > Well, > > (a) works fine I can't test this since tools.greeting is greeterGreeting, which needs a greeter object, and you've left no way of creating any of those... When I reinsert newgreeter() into the library to create greeter objects, it works. > (b) works fine if i cannot add any arguments, but if I write > tools.getprojectpath(22) (I want to check luaL_error statement...) > > pipmak crash with this error: No crash for me, it works as intended both with and without arguments. > (c) always crash with the error above That's quite surprising since tools.newgreeter is the same C function as tools.greeting, which worked in (a). It works for me. Though tools.newgreeter("test") is not a valid call and rightfully complains "bad argument #1...". This is all on Mac OS X, I haven't tried on Windows. > What is wrong? I think that my code is correct. > Do you have any ideas? > function init() is correct? Or i have to do something other to create > library "tools"? Given these experiences, your code seems to be correct, and the problem apparenty lies in your build setup. Perhaps there's an incompatibility between the version of Lua contained in Pipmak.exe and the one you link into your plugin (assuming you do that)? Try again with Pipmak.exe.a, I'd say. -Christian |