Is there any info and tutorials on wrapping and binding things for freebasic?
Is there any info and tutorials on wrapping and binding things for freebasic?
Is there any info and tutorials on wrapping and binding things for use in Freebasic? This is something I really want to learn but I have no idea where to start. Specifically, I want to wrap basic sections of the c++ steamworks api to fb though I probably couldn't do that right off, I have to start learning some time.
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
A C++ API is hard or impossible to access directly from FreeBasic; If the library doesn't provide a C API it's probably better to write a C wrapper in C++ and create binding for that wrapper.
These pages in the wiki contain some general information:
http://freebasic.net/wiki/wikka.php?wak ... ngCreation
http://freebasic.net/wiki/wikka.php?wak ... StyleGuide
Unfortunately a tutorial / step-by-step guide is not available at the moment:
http://freebasic.net/wiki/wikka.php?wak ... lateHeader
I'd start with fbfrog (https://github.com/dkl/fbfrog) and correct errors manually afterwards.
These pages in the wiki contain some general information:
http://freebasic.net/wiki/wikka.php?wak ... ngCreation
http://freebasic.net/wiki/wikka.php?wak ... StyleGuide
Unfortunately a tutorial / step-by-step guide is not available at the moment:
http://freebasic.net/wiki/wikka.php?wak ... lateHeader
I'd start with fbfrog (https://github.com/dkl/fbfrog) and correct errors manually afterwards.
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
Does this mean It already has C support?--deleted--
Last edited by Boromir on May 21, 2017 23:10, edited 2 times in total.
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
Yes.Boromir wrote:Does this mean It already has C support?
That makes using the library a lot easier as you can use it directly from FreeBasic without any wrappers (you "just" need to translate the headers (or: the parts of it that you need))
But you may run still into problems if they haven't implemented it for all the functionality accessible from C++ (in case you need such a function). Sometimes when both C and C++ APIs are available the C API only provides limited functionality compared to the C++ API. As your library and its documentation aren't publicly available, I could not take a look on it.
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
I got fbfrog and attempted it on steamworks.
cmd executed
"fbfrog steam/steam_api.h"
it gets stuck after printing
[ 1/23] linux-x86
It works fine with the headers in the test folder.
cmd executed
"fbfrog steam/steam_api.h"
it gets stuck after printing
[ 1/23] linux-x86
It works fine with the headers in the test folder.
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
Hi,
looks like a bug in fbfrog, I think it hangs on the C++ code in steam_api.h.
The "flat C-style API" seems to be in steam_api_flat.h. It still contains some C++ things which makes fbfrog choke, but nevertheless, I got fairly good results by doing this:
looks like a bug in fbfrog, I think it hangs on the C++ code in steam_api.h.
The "flat C-style API" seems to be in steam_api_flat.h. It still contains some C++ things which makes fbfrog choke, but nevertheless, I got fairly good results by doing this:
Unfortunately, there are too many types and enums missing, it can't be used as-is (not even in a C program). I guess it would be possible to work-around that by defining the missing types and enums manually based on the C++ headers, and get a complete header and ultimately a compatible binding, but that would surely be a lot of work.fbfrog steam/steam_api_flat.h -define S_API -define class -define bool _Bool
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
Yeah I saw this too but then I saw the note about having built in flat C-style API and I thought it was preferable.D.J.Peters wrote:Here is the C++ to C API wrapper https://github.com/rlabrecque/CSteamworks
Joshy
I tried fbfrog on this and it created a file full of TODOs. I assume I'm doing something in the wrong order because I don't know which .h files to feed fbfrog. I used "steam_api_c.h" in the wrapper folder but at looking at the generated .bi I see it is referencing an in existent "CSteamworks.bi"
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
Looks like CSteamworks is for advanced users
you have to build the C++ wrapper self at first
and than build from the *.h files the right *.bi files.
Is there no official C API in the Steamworks SDK ?
Joshy
you have to build the C++ wrapper self at first
and than build from the *.h files the right *.bi files.
Is there no official C API in the Steamworks SDK ?
Joshy
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
I did build it. It was a matter of running the python script.D.J.Peters wrote:You have to build the C++ wrapper self at first
That's when it made me a bi file with a list of TODO'sD.J.Peters wrote: and than build from the *.h files the right *.bi files.
It does have the flat C-style apiD.J.Peters wrote: Is there no official C API in the Steamworks SDK ?
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
Don't build a C++ wrapper yourself if not absolutely necessary - and it shouldn't as the flat-api is already such a wrapper. That would be just useless work and a possible source for errors.
You don't seem to be aware that very likely manual fixes and manual code translation/writing will be required. If you are not willing or able to do that it probably won't work.
You don't seem to be aware that very likely manual fixes and manual code translation/writing will be required. If you are not willing or able to do that it probably won't work.
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
I understand it's a lot of work and I most certainly am not skilled in this. But I must start somewhere though maybe do something simpler before tackling this.St_W wrote:You don't seem to be aware that very likely manual fixes and manual code translation/writing will be required. If you are not willing or able to do that it probably won't work.
Re: Is there any info and tutorials on wrapping and binding things for freebasic?
Probably you will need only a few methods from the API at the beginning. So to get familiar you could try to pick only a few function definitions and write FreeBasic headers and a sample (test-)application for those. Maybe you can also use parts of automatically generated code by fbfrog or similar tools. If you run into a problem for a concrete method don't hesitate do ask here, but don't forget to include the original C declarations and describe the problem accurately.Boromir wrote:But I must start somewhere though maybe do something simpler before tackling this.