[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference star::wizards

Title: "ASK THE WIZARDS"
Moderator:QUARK::LIONEL
Created:Mon Oct 30 1995
Last Modified:Mon May 12 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1857
Total number of notes:3728

1692.0. "Closed: how to link the C++ and FORTRAN?" by STAR::JKEENAN () Fri Mar 21 1997 13:38

Return-Path: "VMS001::WWW"@vms001.das-x.dec.com
Received: by vmsmkt.zko.dec.com (UCX V4.1-12, OpenVMS V6.2 VAX);
	Tue, 18 Mar 1997 11:11:30 -0500
Received: from vms001 by mail12.digital.com (8.7.5/UNX 1.5/1.0/WV)
	id LAA03227; Tue, 18 Mar 1997 11:07:41 -0500 (EST)
Date: Tue, 18 Mar 1997 11:09:55 -0500
Message-Id: <[email protected]>
From: "VMS001::WWW"@vms001.das-x.dec.com (18-Mar-1997 1110)
To: [email protected], [email protected], [email protected]
Subject: Ask the Wizard: '[email protected]'
X-VMS-To: [email protected]

Remote Host: (null)
Browser Type: Mozilla/2.0 (compatible; MSIE 3.01; Windows 95)
Remote Info: <null>
Name: Steve Frost
Email Address: [email protected]
CPU Architecture: Alpha
Version: v 6.2
Questions: 

Probably a dumb question and I'm sure it's some simple qualifier or option but ...

When trying to call a Fortran (V6.1-386) routine from
a C++ (V5.3-005) main, we get an unresolved reference during the link (LINK version A11-20) of "subroutine__XV".  

For example:

    C++ main of HELLO
    FORTRAN sub HELLOWORLD
    LINK HELLO,HELLOWORLD

%LINK-W-NUDFSYMS, 1 undefined symbol:
%LINK-I-UDFSYM,  HELLOWORLD__XV 
%LINK-W-USEUNDEF, undefined symbol HELLOWORLD__XV referenced 

If instead:

   C++ main of HELLO
   C++ sub HELLOWORLD
   LINK HELLO, HELLOWORLD

then no problem as the HELLOWORLD.OBJ created by C++ has the HELLOWORLD__XV symbol, the OBJ created by FORTRAN doesn't.

How do we successfully link the C++ and FORTRAN?

Thanks.
T.RTitleUserPersonal
Name
DateLines
1692.1QUARK::LIONELFree advice is worth every centFri Mar 21 1997 15:347
The C++ compiler is "name mangling" the Fortran routine name.  To prevent it
from doing this, you must declare the name using

	extern "C"

Please see the DEC C++ manuals for more information on this and mixed-language
programming.