Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding Lua Modules for LuaInterface
    primarykey
    data
    text
    <p>I have a Lua module (<a href="https://github.com/LuaDist/lpack" rel="nofollow">lpack</a>) that I need to load into LuaInterface. I've tried a few different configurations for the project, but I can't seem to figure out the linking. </p> <p>I get the error <code>unresolved external symbol "void __stdcall lua_replace(struct lua_State *,int)" (?lua_replace@@YGXPAUlua_State@@H@Z) referenced in function "int __stdcall l_unpack(struct lua_State *)" (?l_unpack@@YGHPAUlua_State@@@Z)</code></p> <p>If I run <code>dumpbin /exports</code> on the lua51.lib file, I can find <code>?lua_replace@@YAXPAUlua_State@@H@Z</code> which matches what I find in the lua51.dll with Dependency Walker <code>?lua_replace@@YAXPAUlua_State@@H@Z</code>, so the function exists but the names don't match.</p> <p>I'm not very familiar with this level of linker management, so this may be a simple error on my part. Why is the value in the lpack build not matching that of the lua51.lib input file?</p> <p><strong>Update</strong></p> <p>All of the exports in the lua51.dll and lua51.lib files were <code>__cdecl</code> and my lpack project has been set to <code>__stdcall</code>. Changing that property (under C/C++ -> Advanced -> Calling Convention) fixed the compile issue and I now have an lpack.dll file.</p> <p>However, when I attempt to load the file from lua <code>require('lpack')</code> it fails with <code>The specified procedure could not be found.</code> </p> <p>Breaking in the lua C code that loads the library with LoadLibraryA returns NULL and a GetLastError() code of 0x7F.</p> <p><strong>Update 2</strong></p> <p>The lpack.dll file I was attempting to load was out of date due to a wrong output directory, so that fixed the LoadLibrary failure. Next the GetProcAddress would fail, but if I added <code>extern "C"</code> to the export function in the lpack.c file as per Mud's recommendation, the problem was resolved.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload