Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

linking to a FORTRAN library

Posted on 1997-04-04
1
Medium Priority
?
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
dominus earned 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to implement Singleton Design Pattern in Java.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses

618 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