Page 3 of 4

Re: HELP! How to make a dll available for Love2D ?

Posted: Mon Apr 27, 2015 12:47 am
by dracula004
I~=Spam wrote:
dracula004 wrote:The source was already attached in former post.

I'm trying to build that dll with vs.
I downloaded the source before (and just now) and there are no c or c++ files in there. Can you post the C/C++ source (not just lua) The .dll file is not really any help.
It's the C::B project. C source included.
lovedoubles.7z:
download/file.php?id=11569

Re: HELP! How to make a dll available for Love2D ?

Posted: Mon Apr 27, 2015 5:49 am
by I~=Spam
I feel pretty stupid now.... :death: Ok it is really late where I live so I can't do anything tonight but after a quick glance your code looks fine but because LOVE uses luaJIT (assuming you are using LOVE version 0.9.x) not just plain lua make sure you are using the luaJIT c headers instead of lua ones. The names of the files are exactly the same because luaJIT strives to be a drop in replacement but you need to make you you compile you code for luaJIT not lua because it will crash if you try otherwise. If are using the right headers I will look at this tomarrow... ;) (For you debug function it might be useful to note that luaJIT adds a new lua type the "ctype".)

I have done this before so I should be able to help you to get this running. Sure it was linux I got it working on because that is my OS of choice but I can boot the dusty windows partition of my comp. :nyu:

Re: HELP! How to make a dll available for Love2D ?

Posted: Mon Apr 27, 2015 10:14 pm
by I~=Spam
Your code works just fine in linux LOVE. I haven't tried windows yet. Are you making sure that the library architecture (ie. 32bit/64bit) is the same as the LOVE executable that is loading your program?

Re: HELP! How to make a dll available for Love2D ?

Posted: Wed Apr 29, 2015 7:49 am
by dracula004
I~=Spam wrote:I feel pretty stupid now.... :death: Ok it is really late where I live so I can't do anything tonight but after a quick glance your code looks fine but because LOVE uses luaJIT (assuming you are using LOVE version 0.9.x) not just plain lua make sure you are using the luaJIT c headers instead of lua ones. The names of the files are exactly the same because luaJIT strives to be a drop in replacement but you need to make you you compile you code for luaJIT not lua because it will crash if you try otherwise. If are using the right headers I will look at this tomarrow... ;) (For you debug function it might be useful to note that luaJIT adds a new lua type the "ctype".)

I have done this before so I should be able to help you to get this running. Sure it was linux I got it working on because that is my OS of choice but I can boot the dusty windows partition of my comp. :nyu:

Maybe luaJIT is the point. I built the lib with plain lua. I'll have a try with luaJIT. And thx much.

Re: HELP! How to make a dll available for Love2D ?

Posted: Wed Apr 29, 2015 3:36 pm
by I~=Spam
I seemed to be wrong with my previous statement because in linux I compiled with this:

Code: Select all

g++ -fpic -llua -ldl -shared main.cpp -o lovelib.so
'

The "-llua" means I was just linking against plain lua (if I understand correctly). But this is linux so the build process might be different or more flexible somehow.

Have you checked that are are not compiling a 32bit lib when you should be compiling a 64bit lib? I recommend you download the 64bit and 32bit versions of LOVE and try it out with each. If the library doesn't match and lua tries to call code from your lib it is almost certain that it will crash. (unless lua is nice enough to detect a mismatch which I doubt because that probably won't follow the ANSI C standard which lua has gone to incredible lengths to follow.)

Re: HELP! How to make a dll available for Love2D ?

Posted: Wed Apr 29, 2015 3:45 pm
by bartbes
Note that luajit is compatible with lua 5.1, not lua 5.2 (or 5.3), if you linked your library against the latter, it won't work in love.

Re: HELP! How to make a dll available for Love2D ?

Posted: Wed Apr 29, 2015 5:01 pm
by I~=Spam
Ahh didn't think of that! That might be it. So linking directly against lua 5.1 or luajit should work (and make sure you binary architectures match ;) )

If you are getting sick of waiting you could just download the LOVE source and just add your own module and functions directly for there. :) That is what I would do unless I wanted others to be able to use my .love file. :3

Re: HELP! How to make a dll available for Love2D ?

Posted: Thu Apr 30, 2015 3:11 am
by RBXcpmoderator12345
I think libraries are supposed to be in .lua format, not .dll format...

Re: HELP! How to make a dll available for Love2D ?

Posted: Thu Apr 30, 2015 9:30 am
by Nixola
Lua libraries should be a .lua file, but C/C++ libraries (which will of course be faster if well written) have to be a .dll/.so/.dylib file.

Re: HELP! How to make a dll available for Love2D ?

Posted: Sun May 03, 2015 6:47 am
by dracula004
I~=Spam wrote:I seemed to be wrong with my previous statement because in linux I compiled with this:

Code: Select all

g++ -fpic -llua -ldl -shared main.cpp -o lovelib.so
'

The "-llua" means I was just linking against plain lua (if I understand correctly). But this is linux so the build process might be different or more flexible somehow.

Have you checked that are are not compiling a 32bit lib when you should be compiling a 64bit lib? I recommend you download the 64bit and 32bit versions of LOVE and try it out with each. If the library doesn't match and lua tries to call code from your lib it is almost certain that it will crash. (unless lua is nice enough to detect a mismatch which I doubt because that probably won't follow the ANSI C standard which lua has gone to incredible lengths to follow.)
But obviously, it is not about 32/64 bit. I used 32 bit both in LUA and LOVE.
It's just kinda weird.
I know that there must be something wrong, but i just can not find where goes wrong.