How to add a C library in linux?

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
pocoyo
Prole
Posts: 2
Joined: Mon Aug 28, 2023 6:53 pm

How to add a C library in linux?

Post by pocoyo »

Hi everyone.
I'm trying to add a library to the Love2D source code. (The main goal is to expose it as a module on lua). In Windows it was easy using vcpkg, just #include'ing the library compiled and worked.
However in Ubuntu the compilation throw errors, as it is not finding the library functions. In gcc I would use the flag -llibname to make it know about the library. It seems I would need to edit the CMakeList.txt file, however I'm a total noob on cmake.
How could I do that?
Thanks in advance!
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to add a C library in linux?

Post by zorg »

Do you need to modify löve itself though? Can you not just require in the c library?
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
pocoyo
Prole
Posts: 2
Joined: Mon Aug 28, 2023 6:53 pm

Re: How to add a C library in linux?

Post by pocoyo »

You mean, like in this tutorial? I guess so. I thought it would be faster to have the code directly in the executable. The library contains functions specific to a hardware platform.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: How to add a C library in linux?

Post by slime »

There won't be a difference, performance-wise. It generally takes more effort to modify love instead of having a standalone library, so the former is slower to implement.

If runtime performance is really important, you'd probably want to use LuaJIT's FFI to call C functions that are in your standalone library instead of creating C bindings with stock Lua's C API. It will be a lot faster when the surrounding code is able to be JIT-compiled.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 6 guests