Hi, I'm experimenting and trying to make a collision manager dll, following these two pages
http://www.mingw.org/wiki/sampleDLL
http://www.troubleshooters.com/codecorn ... alls_c.htm
But when I try to require the library from Love, it gives me this
error loading module 'test' from file '.\test.dll':
%1 is not a valid Win32 application.
I also tried ffi, but it just gave me a nil
I'm baffled and don't know where to go next, please help?
External C dll
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: External C dll
Be sure to build it for the same architecture as your copy of LÖVE - i.e. make a 32 bit build if you're running 32 bit love, or a 64 bit build if you're running 64 bit love.
- giantofbabil
- Prole
- Posts: 32
- Joined: Tue Dec 15, 2015 6:07 pm
Re: External C dll
I'm pretty new to Love2D and programming in general but what is the advantage of a .dll over another .lua file to manage something?
Code: Select all
if enemy == lowerClassSaiyan and powerLevel > 9000 then
love.graphics.print("What?! 9000?! There's no way that could be right!", 10, 200)
else
love.graphics.print("You fool!", 10, 200)
end
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: External C dll
C code could potentially be faster or flexible. But there is more disadvantages than advantages. Better off using ffi if you want to use c to boost the performance
-
- Prole
- Posts: 2
- Joined: Sun Dec 20, 2015 5:02 am
Re: External C dll
Aw, I always forget about that!slime wrote:Be sure to build it for the same architecture as your copy of LÖVE - i.e. make a 32 bit build if you're running 32 bit love, or a 64 bit build if you're running 64 bit love.
Now ffi gives me
missing declaration for symbol 'test'
and require gives me
error loading module 'test' from file '.\test.dll':
The specified procedure could not be found.
But I think I did it right
int __declspec(dllexport) test(int num){
return num+5;
}
gcc -shared -o test.dll test.c -Wl,--out-implib,test.a
and I also tried
gcc test.c -shared -o test.dll -Wl,--no-undefined,--enable-runtime-pseudo-reloc
and I also tried adding __stdcall to the function, but I don't really know what that does
Re: External C dll
I don't see any Lua code here so I'll just go out on a limb and guess that the error's exactly what it looks like and the symbol was never declared (something like ffi.cdef 'int test (int);').Now ffi gives me
missing declaration for symbol 'test'
This is covered at the very beginning of the documentation for the ffi api.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest