Git Product home page Git Product logo

Comments (7)

bebbo avatar bebbo commented on August 28, 2024

Sorry, no plans.
But for public interest: you should link/provide that example!

from amiga-gcc.

krabobmkd avatar krabobmkd commented on August 28, 2024

Hello again,
According to official documentation, a .library file is same format as an exe, but just does moveq ΒΈ-1,d0 / rts , then there is a constant sized structure with flags, and then the vector of function pointers in which the 4 firsts are the Open() / Close() / Expunge() functions that are used when doing OpenLibrary() /CloseLibrary() and Expunge() is used when Library is flushed, ... then a null pointer, and then only: the library public exported API as function pointers, corresponding to what a fd file describes.

This is well explained in this short asm example that does compile a valid .library:
https://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node058C.html

I may be wrong, but enclosing static-linked C++ inside an Amiga library with C Api would "just" implies the static inits usually done before entering main() in an exe, would be done in that Open() call, and then closed in the expunge() call. There is something about data allocated for each caller in the documentation, but for a pure "re-entrant" api, which is the case of what I want to port, and most "well done" codes, this is not even needed.

... StormC4 used to patch GCC2.5 but used their own format for makefiles, and I bet they never published their linker sources. there is something called "stormlink" that allows to link a library. in that case the first .o linked is "gcclibrary_startup.o" , which I inspected, and it is exactly looking like the structure described in the link, with names to be replaced... The whole AmigaOS 3.9 must have been compiled with that, This was done by the same team if i'm correct.

I may investigate further myself If there's no plan for generating libraries... I noted that doing gcc -shared would generate a legit "68k elf .so file" ... maybe coding a "dlopen() using 68k elf" on amiga would be a solution.

For information, I have a pistorm here and I've ported a static version of "libheif" , something to read the new .heic image format of the phones. The example "convert-heif" is already 90% working , yet a few of the iOS images I tested have glitchs, but the exe looks stable. it embbeds also libde265, the h265 codec (!). libheif is done in C11 with shared_ptr<> and all, but then the API is very C-looking and would fit a .library and fd file.

My plan is to have a heif.library , and then doing a "datatype class" to allow Amiga Apps to read the images directly, that would use the library. As their is a USB MTP driver with the Amiga Poseidon USB stack, this would allow to read images from modern androids directly.

... If I have a way to generate shared libraries with gcc6, then I would also try to do a python3 port.

from amiga-gcc.

michalsc avatar michalsc commented on August 28, 2024

I am building many shared libraries with this gcc and there are no issues with that. As you have found out yourself shared libraries are executables, just built differently. The issue reported here is actually irrelevant to the gcc project itself, so it could be closed here.

You can find examples of my libraries (build with gcc-6.5 and cmake) can be found here:
https://github.com/AmigaPorts/UUID
https://github.com/michalsc/Emu68-tools

from amiga-gcc.

krabobmkd avatar krabobmkd commented on August 28, 2024

Thanks a lot mister Schulz. I'll just looked at that.

The issue reported here is actually irrelevant to the gcc project itself,

The thing is, newcomers will endlessly try to build shared libraries with the common gcc options. using -nostartfiles and using a init.c to make the executable header is not that intuitive nor documented... Plus, I will look further into your examples, but ideally the .library should also manage the init/close of the C++ runtime.

All thatshould be documented somewhere.

( and also thanks because I am a very happy piStorm user.)

from amiga-gcc.

michalsc avatar michalsc commented on August 28, 2024

Yeah, unfortunately AmigaOS shared libraries are completely different from what you know in case of other operating systems, so making a shared .library cannot be done just by adding a -shared compiler flag. Amiga libraries will always need more work and more boilerplate code.

But you're right, a topic like how to create shared library or .device file in pure C or C++ should be documented somewhere as it would probably help many :)

from amiga-gcc.

bebbo avatar bebbo commented on August 28, 2024

Yeah, unfortunately AmigaOS shared libraries are completely different from what you know in case of other operating systems, so making a shared .library cannot be done just by adding a -shared compiler flag. Amiga libraries will always need more work and more boilerplate code.

But you're right, a topic like how to create shared library or .device file in pure C or C++ should be documented somewhere as it would probably help many :)

Wrong: Now shared libraries can be done just by adding a -shared compiler flag!

from amiga-gcc.

bebbo avatar bebbo commented on August 28, 2024

Read more here: https://franke.ms/amiga/so.wiki

from amiga-gcc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.