Creating a C library #155
-
So I've been messing around with SDL2, tigr and kit. What I've done so far is just take those libraries and compile them like:
And while this does create a My test library currently looks like so: var lib = clib.load('./kit.dll')
var kit_create = lib.define('kit_create', clib.ptr, clib.char_ptr, clib.int, clib.int, clib.int)
def create(title, w, h) {
return kit_create(title, w, h, 0)
}
var kit_step = lib.define('kit_step', clib.bool, clib.ptr, clib.ptr)
def step(ctx) {
return kit_step(ctx, clib.double)
}
var kit_destroy = lib.define('kit_destroy', clib.void, clib.ptr)
def destroy(ctx) {
kit_destroy(ctx)
} There's currently some issues with using structs, and it also seems to run inconsistently. What I was thinking is, would it be better if I made a wrapper library in C, using |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 10 replies
-
Have you checked out the blade-ext-demo repository?? That's an example repository showing how to achieve this easily. Though the project uses cmake, it's not exactly a requirement. The basic requirements are:
You can learn more about the API by looking at the builtin-packages under the |
Beta Was this translation helpful? Give feedback.
-
Yeah but does this build an entirely new Blade executable or DLL with those libraries? |
Beta Was this translation helpful? Give feedback.
-
No. It generates a Blade extension dll. If you create a directory For example, if you build the demo project, it will create a import demo
demo.say_hello() You should be greeted by Also, note that the |
Beta Was this translation helpful? Give feedback.
-
Do you have the
|
Beta Was this translation helpful? Give feedback.
-
Alright, your make suggestion made it work! Here's a GIF of a window opening with a loop! But, I'm having my hard time wrapping my brain around, how to make it a Blade module. Do I just keep the DLL files in the It might be a vague question. But even though I've looked at the |
Beta Was this translation helpful? Give feedback.
-
Your suggestion works perfectly. You can convert it into a |
Beta Was this translation helpful? Give feedback.
-
Quick suggestion, you could use Also, which editor is this and how were you able to make it recognise Blade syntax?? I'm really interested. |
Beta Was this translation helpful? Give feedback.
-
Sort of related last thing. |
Beta Was this translation helpful? Give feedback.
-
This came to my attention again specifically the statement " See the structs documentation. |
Beta Was this translation helpful? Give feedback.
-
I've been busy with school and work so I haven't gotten around to the raylib library for Blade. But I can see that you have started Blade projects based on raylib and raygui for these 😄 Do you still want me to make a 1:1 raylib library? |
Beta Was this translation helpful? Give feedback.
Do you have the
mingw32-make
in your path?? If you don't, you can get it by installing TCC or WinLibs compiler and adding it to your path (Or simply add the directoryC:/mingw64/bin/
to your path based on what I see). Without changing anything in the CMakeLists.txt file and provided that theblade.exe
resides in the directoryD:/Projects/Blade/blade/build/blade
, you can change the first command to: