- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to invoke functions and procedures in Ada source code developed under Aonix ObjectAda IDE from a FORTRAN project developed under Microsoft Developer Studio (Compaq Visual FORTRAN). Defining a link (under MDS) to the Ada library causes a "can't open file" error when attempting to build under MDS. It's possible to dump C++ code directly into the FORTRAN project and invoke it from the FORTRAN; but when the same thing is attempted with the Ada source code, it shows up as text files (MDS evidently being unable to recognize the .ads/.adb file extensions). How can I get the FORTRAN to "see" the Ada code or construct a successful link to the Ada library?
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, Ada - one of my favorite languages. I worked for five years on VAX Ada and VAXELN Ada for DEC, and spent a week with Jean Ichbiah at his company Alsys in France.
The CVF environment doesn't know Ada source. If your Ada compiler can create object files that are linkable with Microsoft Visual C++, then you can add the objects to the project. If the Ada can create DLLs, you can call the DLL. You will also need to make sure that the calling and naming conventions are followed. For help with this I suggest you contact the support for your Ada compiler - tell them that you want to build a mixed-language application with Microsoft Visual C++ - whatever they tell you for MSVC will almost certainly hold for Compaq Visual Fortran.
The CVF environment doesn't know Ada source. If your Ada compiler can create object files that are linkable with Microsoft Visual C++, then you can add the objects to the project. If the Ada can create DLLs, you can call the DLL. You will also need to make sure that the calling and naming conventions are followed. For help with this I suggest you contact the support for your Ada compiler - tell them that you want to build a mixed-language application with Microsoft Visual C++ - whatever they tell you for MSVC will almost certainly hold for Compaq Visual Fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
Thanks. I suspected CVF couldn't recognize the Ada code. I believe the object files linkable to C++ and the .DLLs are both approaches we can try here.
jch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
As you recall, my initial question concerned calling Ada functions and procedures from FORTRAN. Since it appears that is unworkable with Compaq Visual FORTRAN, I've been pursuing the angle of calling C++ from FORTRAN and then having the C++ call Ada.
I tried this out first with Microsoft Visual C++ and a demo version of Aonix ObjectAda. The Aonix documentation contains an explicit example of C++ calling Ada. Once I identified and eliminated the errors in the example, it almost worked; but I hit a snag in that the Aonix Ada libraries would not link to the C++ code. It appeared the Ada libraries needed to be compiled; but the demo version of ObjectAda won't compile a file containing in excess of 2,000 lines, and some of the library files are larger than that.
I next tried this out with MSV C++ and a full version of GNAT Ada95, and again it almost worked; but again I ran into a problem with the ADALIB library. One of the Ada packages has a "with Text_IO," so when the C++ compiler tries to link with the Ada library, it goes looking for something like _ada_text_io.obj; but the object file is called A-TEXTIO.O. I believe something on the Ada side of things "knows" that "Text_Io" in a calling package is to be associated with the ADALIB object called A-TEXTIO.O; at least I think that's the way it works. But if it is, the C++ side of things doesn't know that. I tried adding A-TEXTIO.O to the C++ list of objects to be linked, and C++ appeared to be happy with that; but, of course, doing that dragged in additional dependencies, so the overall build failed. I suppose I could add all the ADALIB object files to the C++ link list; but that's a large number of files. Alternatively, it seems as if I could add pragmas specifying the appropriate link names to the ADALIB .ads and .adb files and recompile them; but the GNAT compiler I have won't let me do that.
I imagine there are other alternatives; but the MSV C++ documentation seems to have been written as a memory refresher for somebody who already knows all the answers.
Do you have any advice?
jch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may just need to add the path to the Ada library directory to Tools..Options..Directories. I really can't help you much with this other than to say that if it works with MSVC, it will almost certainly work with CVF.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page