[SOLVED]HELP! How to make a dll available for Love2D ?

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.
User avatar
dracula004
Prole
Posts: 17
Joined: Tue Mar 03, 2015 2:50 am
Location: Asia

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

Post 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
github:https://github.com/Nigh

email:xianyi.xia#outlook.com
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

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

Post 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:
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

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

Post 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?
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
dracula004
Prole
Posts: 17
Joined: Tue Mar 03, 2015 2:50 am
Location: Asia

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

Post 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.
github:https://github.com/Nigh

email:xianyi.xia#outlook.com
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

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

Post 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.)
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post 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.
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

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

Post 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
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
RBXcpmoderator12345
Citizen
Posts: 59
Joined: Sat Mar 07, 2015 11:53 pm

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

Post by RBXcpmoderator12345 »

I think libraries are supposed to be in .lua format, not .dll format...
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

Post 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.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
dracula004
Prole
Posts: 17
Joined: Tue Mar 03, 2015 2:50 am
Location: Asia

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

Post 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.
github:https://github.com/Nigh

email:xianyi.xia#outlook.com
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests