[SOLVED] Trying to load a DLL: "The specified procedure could not be found."

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
NetherGranite
Prole
Posts: 30
Joined: Wed Jul 11, 2018 11:08 pm

[SOLVED] Trying to load a DLL: "The specified procedure could not be found."

Post by NetherGranite »

I'm porting one of my more computationally intensive Lua libraries to C, but trying to load the dll I'm compiling this library to gives me the following error:

Code: Select all

Error

error loading module 'lib.DepthBuffer' from file '.\lib\DepthBuffer.dll':
The specified procedure could not be found.



Traceback

[C]: at 0x635da030
[C]: in function 'require'
main.lua:12: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
How can I fix this? I haven't been able to find anything on the internet that helps.

So far, that dll consists of the following bare-bones code:

Code: Select all

int test(lua_State * L)
{
	return 0;
}

int main()
{
	lua_State *L = lua_open();

	luaL_openlibs(L);

	static luaL_reg staticMethods[] = {
		{"test", test},
	};

	luaL_register(L, NULL, staticMethods);

	lua_close(L);
	return 0;
}
Last edited by NetherGranite on Tue Oct 09, 2018 8:58 am, edited 2 times in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Trying to load a DLL: "The specified procedure could not be found."

Post by grump »

Lua calls luaopen_lib.DepthBuffer when you require() the dll. You can either move the dll and provide that function or use package.loadlib.
User avatar
NetherGranite
Prole
Posts: 30
Joined: Wed Jul 11, 2018 11:08 pm

Re: Trying to load a DLL: "The specified procedure could not be found."

Post by NetherGranite »

grump wrote: Tue Oct 09, 2018 7:09 am Lua calls luaopen_lib.DepthBuffer when you require() the dll. You can either move the dll and provide that function or use package.loadlib.
Thanks, that was the solution. I ended up just changing the require path. In case someone else is reading this, you change the require path by using love.filesysem.setRequirePath().

Edit: It also turns out this can be solved by naming the function "luaopen_lib_DepthBuffer".
Post Reply

Who is online

Users browsing this forum: No registered users and 47 guests