Loading Ada shared objects in Perl with DynaLoader.pm

后端 未结 2 1518
别那么骄傲
别那么骄傲 2021-02-20 09:52

Long time listener, first time caller. I\'m aware this is a somewhat obscure question, and don\'t expect too much. :-)

I have the following Ada files:

gr

2条回答
  •  我在风中等你
    2021-02-20 10:37

    I'll do the best I can with this, given not much Perl knowledge.

    It looks to me like the Dynaloader in perl is a utility that lets you load dynamicly loadable libraries (lib*.so's on Unix systems) into a perl program.

    For that to work for an Ada program, there are several things you'll need to take into account.

    1. You need to build your Ada program as a proper dynamic library. It looks like you did that. However, I'm no expert on this, so perhaps you missed something. I'd highly suggest looking over TFM on this.
    2. You need to call your Ada code properly. Ada programs generally require a process called "elaboration" be performed before any actual code may be run. To accomplish this, most Ada compilers create a special entry-point to the program, rather than just using the one associated with your "main" routine. I think Gnat's is something like C_yourprogramname, but don't hold me to that. Even if you are implementing a library of some sort, the elaboration should be run first (execpt in some special circumstances, that do not apply here). However, if you want a routine to be a library routine called from outside of Ada, you generally don't want a "main", so there are some extra steps. How to do this with Gnat is described in their user guide, but in general it involves telling the compiler to not make a "main", calling adainit before running any Ada routine from outside, and calling adafinal when you are all done.

提交回复
热议问题