Solved

linking to a FORTRAN library

Posted on 1997-04-04
1
333 Views
Last Modified: 2013-12-26
I have been trying to create a *.a library from many FORTRAN mathematical subroutines.  I don't think I'm doing it right because when I try to link it to a C program I'm compiling, I get the following error message:
/bin/ld : Unsatisfied symbols:
   ddriv1 (code)
*** Error code 1

ddriv1 is the subroutine that my C program needs from the library.  I'm very new at this, so please don't assume much technical knowledge.  I'm using an HP 9000-700 running HP-UX 9.0, HP FORTRAN 9000, and HP C.  Any help would be greatly appreciated.
0
Comment
Question by:birkedal
1 Comment
 

Accepted Solution

by:
dominus earned 100 total points
ID: 1292517
Part I:

First, you need to make sure you built the .a ilbrary properly.  try `nm library.a' and make sure that the output mentions the `ddrv1' function.  If not, come back here and say what commands you used to compile and build the library.

Part II:

1. The fortran and C compilers may have different conventions about the names that they store the objects under in the .o file.  Here's what you can do:

2. Create a ddriv.c file that just says
      int ddriv1(void) { return 1; }
and compile it into a .o file.

3. Use `nm' on the .o file to find out what the symbol name
is in the .o file. Let's say it is `_ddriv1', which is typical.
Now you know what the C compiler is expecting to call when it compiles your C code.

4. Use `nm' on the fortran `.a' library to see what the symbol names are there.  Perhaps you'll see, for example, that the fortran version of `ddriv1' compiled into a symbol named
`ddriv1' (no leading underscore) or `DDRIV1'.  Now you know how
the ortran compiler compiles the function.

5. If the C versions and Fortran versions are the same, come back here and show us the exact commands you use to compile and to attempt to link the program.  If not:

6. Adjust the fortran code and/or the C calling code appropriately, so that the symbol name generated by the fortran compiler is the same as the one that the C compiler was expecting.  

For example, if the fortran compile compiles `ddriv1' as `DDRIV1', when the C compiler was expecting it to be `_ddriv1',
then you should change the name of the fortran function
to `_ddrv1' and fix up the C code to call `DDRV1' instead of `ddriv1'.  Then the compiled symbol names will match.

7. Alternatively, there may be a command-line option to the fortran compiler to tell it to make the symbol names different.

-dominus
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sum13 challenge 24 90
fizzArray3  challenge 1 77
Python - ImportError: No module named 'urllib2' 2 155
Problem to error 4 46
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now