C Linklibs to Libraries

Posted by ALB42 on 5. Oktober 20154 Comments

Currently we are only able to use the shared AROS .libraries, so every C link lib is not available in freepascal for AROS. For example sqlite3, SDL, GLUT, SSL and and and much things only available as c linklibs.
I tried once long time before to use the c link libs directly but failed because of the „auto library init“ needed by them.

But of course the other way round, maybe would be possible to specially create a library in C which can be used in freepascal later. I’m not very good in C neither in Makefile magic but hey worth a try. First the official documentation is just crap, not existing (many 404 there, seems someone deleted/moved the documentation) or very old (already written in there that it will change in 2006 and the docu gets not updated) and what I found is just a documentation about how to create a library inside the AROS core build process. I don’t want to compile the complete AROS just to get my Library compiled. Shit, luckily I found an other library which had the same problem and which also come with the source (which is rather seldom on Amiga-style systems, but on AROS more common, but there not so many 3rd party libraries available, one I found)
With this it was rather easy to create a own custom build library with a simple function inside.
The next step was to include sqlite3 to the library. I decided for sqlite3 because its the easiest to check for success and even with some functions its already useful. The task sounded easy but exactly there the problems started, as always.

Again the „compiler magic“ autoinit killed me many times. Finally I found out that I can invoke this autoinit from my initialization by hand. And finally it worked.
This is now a single instance library, a pertask library would make more sense but I didn’t find out how to change that behavior (just to change a flag in the libinit structure was maybe too easy for the designer of this system). But for sqlite3 its not a big problem, it mostly work on a db which have to be opened and closed before using and then always must be supplied to the library. There are some calls which are not threadsafe like sqlite3_config or so but they could be protected via a mutex later. So for now not a big problem, maybe later I find a way to switch to pertask behavior.

The library includes now: sqlite3_open(), sqlite3_close(), sqlite3_free(), sqlite3_exec(). Which is enough to create a database, create a table, add some data and make some selections + output which I tested with a tiny pascal program.

The make process is not complete done and understood by me, there I have some more work to do and then one could begin to include all the sqlite3 functions to the library and make some more tests and of course write a pascal wrapper unit 😉

The long term idea would be also again to check how one could use the link libs directly in freepascal, when creating the c library I got much more knowledge how this autoinit things are working, maybe one could copy this to freepascal.

4 comments to "C Linklibs to Libraries"

  1. aha sagt:

    Hi ALB42, I think there already is a sqlite port for AROS. I found this video: http://www.youtube.com/watch?v=tm1FVkNMUC8

    And I found this report from deadwood on aros-exec of an ABI V0-OT port of sqlite3 v3.7.3:
    http://aros-exec.org/modules/newbb/viewtopic.php?post_id=89584#forumpost89584

    • ALB42 sagt:

      I’m not sure you understood my post completely 😉 there is a sqlite3 Port for AROS yes, but only as C Linklib (sqlite3.a) which I cant use for fpc. There I need a shared Library (sqlite3.library). I found such Library only for 68k Amiga.

  2. aha sagt:

    And thank you for all your efforts regarding the fpc port for AROS!

  3. aha sagt:

    @ALB42

    Oh, yes, I did not understand the problem. :-/ Thank you even more then. 🙂

Schreibe einen Kommentar zu aha Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert