help linking msvc and ms-fortran 5.1 subroutine 
Author Message
 help linking msvc and ms-fortran 5.1 subroutine

Hey folks;

Undoubtably this is a faq, but forgive me, I'm slow.

I'm trying to call an ms-fortran 5.1 subroutine (poorly named "yeehah"
which is just for testing to see if it works) with a ms Visual C++ 1.0
main program (nothing more than something that calls the fortran
routine).  My ms-fort is installed for "compatibility with C".

1) I compile the fortran routine into an .obj using the pwb
2) I add the fortran .obj to the list of files on the msvc project
3) I use the following extern declaration in my C program:

extern void __fortran yeehah(float *A, float *B .. etc).

(also, my main program is actually just C, but it's a .cpp
 file so I can use the nice // comments.  Yes, I'm lame)

4) I call the routine as "yeehah(&a, &b, &c etc." in the C code.

I build from within msvc, all goes well until the link stage.. when I
get the famous link error "extern __far __Pascal yeehah etc.. : unresolved
external".

I've tried calling both YEEHAH and yeehah, I've converted my fortran
code from lower to upper case, and I've tried the "ignore case" option
on the msvc project dialog.  I've also tried the "ignore default
libraries" and linking the fortran library by hand.  and I've tried
putting the fortran .obj into a .lib and linking that.

As you can guess, none of this works (if it did, why would I be
bothering all of you?).  All give "unresolved external" for my
fortran routine.

To read the ms c/fortran books, this looks real easy.  I figure I'm just
missing something obvious.  Maybe someone could point me on the newbie
path to linking msvc-msfort?  What exactly do I have to do along all
the steps of this to make it work?

Thanks a lot for your help.  If I get solutions via email I'll post a
summary.  If I've left out some important detail above, let me know. :-)


UNB Fire Science Centre -- Fredericton NB Canada E3B 5A3 -- (506) 453 4509



Fri, 22 Nov 1996 07:19:17 GMT  
 help linking msvc and ms-fortran 5.1 subroutine
Well, here I am to follow up my own post.

: 3) I use the following extern declaration in my C program:
: extern void __fortran yeehah(float *A, float *B .. etc).

Yep, that's right.  Mistake here since I'm compiling as C++ even though
I don't use any features other than the cool comments :-)  It should be:

extern "C" void __fortran yeehah(float *A, float *B .. etc).

a quick change to this was just what it needed.   Works like a charm now.
Now if I could only find out why when I type "llibfore" in the libraries
dialog does it change it to "llibfere" when it tries to link... darn bugs :-)


UNB Fire Science Centre -- Fredericton NB Canada E3B 5A3 -- (506) 453 4509



Fri, 22 Nov 1996 11:48:36 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Linking MS Fortran 5.1 with MS C/C++ 7.0

2. Ms Fortran 5.1 or MS Fortran Powerstation

3. Ms Fortran 5.1 or MS Fortran Powerstation

4. MS Fortran 5.1 DOS linking problems !!!

5. I need help with MS FORTRAN Compiler 5.1

6. MS FORTRAN 5.1, Target setup, HELP!

7. HELP: Need Disk 1/Setup for MS Fortran 5.1

8. HELP: READ DIR in MS Fortran 5.1

9. Help --> MS FORTRAN 5.1

10. help! problems with MS FORTRAN 5.1

11. Please Help: READ Statement Touble when Compiling MS Fortran 5.1 code with Intel DVF 5.0

12. MS Fortran 5.1 and Windows DLL:s, HELP!

 

 
Powered by phpBB® Forum Software