Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

mixed language programming - error
Hi!
I want to call a Fortran Routine from a C++ - program, so I compiled
the fortran part with the fortran compiler (Compaq Visual Fortran) and
appended it to my c++ project (using Microsoft Visual Studio 6.0).

in the c++ program I declared the Fortran routine as following:

extern "C" { void _stdcall
electro1_(int* ,float* ,float* ,bool* ,float* );}

and my call is

electro1_(&hoehe,actual_column_t,actual_column_p,&erster_Aufruf,actual_colum
=
n_xNe);

in the fortran file, the subroutine is defined as

subroutine ELECTRO1 (Nrhox,T,Pgas,if_ndens,xNe)

and it just doesn=B4t work,
I get the errors
error LNK2001: unresolved external symbol _electro1_@20
Debug/tp500.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

any ideas?
thx for all pieces of advice,
Iso

Report this thread to moderator Post Follow-up to this message
Old Post
Isomorphismus
04-03-08 11:27 AM


Re: mixed language programming - error
On 3 apr, 12:27, Isomorphismus <natalieh...@hotmail.com> wrote:
> Hi!
> I want to call a Fortran Routine from a C++ - program, so I compiled
> the fortran part with the fortran compiler (Compaq Visual Fortran) and
> appended it to my c++ project (using Microsoft Visual Studio 6.0).
>
> in the c++ program I declared the Fortran routine as following:
>
> extern "C" { void _stdcall
> electro1_(int* ,float* ,float* ,bool* ,float* );}
>
> and my call is
>
> electro1_(&hoehe,actual_column_t,actual_column_p,&erster_Aufruf,actual_col=[/color
]
u=ADmn_xNe);
>
> in the fortran file, the subroutine is defined as
>
> subroutine ELECTRO1 (Nrhox,T,Pgas,if_ndens,xNe)
>
> and it just doesn=B4t work,
> I get the errors
> error LNK2001: unresolved external symbol _electro1_@20
> Debug/tp500.exe : fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
>
> any ideas?
> thx for all pieces of advice,
> Iso

Yes, a couple:

- You use _stdcall, that is probably the same as __stdcall,
but that is what I use (double underscore).

- The name of the Fortran routine is _ELECTRO1_@20 (after
application of all decorations). So on the C++ side
the name should be ELECTRO1_

- C++'s bool type is not the same as Fortran's logical type.
You will need to convert the values properly.

But the all-uppercase name for Fortran routines is the one
causing the current failure.

Regards,

Arjen

Report this thread to moderator Post Follow-up to this message
Old Post
Arjen Markus
04-03-08 11:27 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:17 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.