From: Isomorphismus on
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_column_xNe);

in the fortran file, the subroutine is defined as

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

and it just doesn´t work,
I get the errors
error LNK2001: unresolved external symbol _electro1_(a)20
Debug/tp500.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

any ideas?
thx for all pieces of advice,
Iso
From: Arjen Markus on
On 3 apr, 12:27, Isomorphismus <natalieh...(a)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_colu­mn_xNe);
>
> in the fortran file, the subroutine is defined as
>
> subroutine ELECTRO1 (Nrhox,T,Pgas,if_ndens,xNe)
>
> and it just doesn´t work,
> I get the errors
> error LNK2001: unresolved external symbol _electro1_(a)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_(a)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
From: Gerry Ford on


"Isomorphismus" <nataliehapp(a)hotmail.com> wrote in message
news:77e25008-f233-4034-8ff0-5dc675be435c(a)u69g2000hse.googlegroups.com...
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* );}

--->
This doesn't look like it's wrapped right, in particular with a statement
within the curly braces. That's the c++ part.

Another gotcha can come from MSVC 6 not being the newest of creatures. It
won't do C99. I'm amazed at how many people are using it lately. I think
its popularity comes from its apps being native on windows as opposed to on
the dot.net framework, which requires users to have the frameowrk as well.

I would think that clc++ could confirm the above syntax with appropriate
please's and thank you's.
--

"That this social order with its pauperism, famines, prisons, gallows,
armies, and wars is necessary to society; that still greater disaster
would ensue if this organization were destroyed; all this is said only
by those who profit by this organization, while those who suffer from it
- and they are ten times as numerous - think and say quite the contrary."

~~ Leo Tolstoy