help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cannot call a C module from Fortran


From: robert . corbett
Subject: Re: Cannot call a C module from Fortran
Date: 23 May 2006 20:05:22 -0700
User-agent: G2/0.2

Cottonwood wrote:
> I want to call a C module from a Fortran program. Whatever I tried -
> the linker could not find the C module. I know about the leading
> underscore and switched even that off. I abstracted everything
> possible. When I replace the C module by a Fortran subroutine linking
> works. Here the Fortran subroutine that replaced the C module for
> testing:
>
>       subroutine qqcprint
>       return
>       end
>
> But when I use this C module in the same library (replacing the Fortran
> testmodule) linking didn't work any longer.
>
> void qqcprint()
> {
> return;
> }
>
> I also tried it with this one:
>
> extern void qqcprint()
> {
> return;
> }
>
> The result was always the same. With the Fortran subroutine linking
> works, with one of the C modules I get the message
>
> qqmodlib.a(qqprint.o):qqprint.for:(.text+0x42): undefined reference to
> `qqcprint'
>
> What am I doing wrong?

Fortran compilers often alter the names of the routines they generate
to
avoid name conflicts with routines written in other languages.  The
most common change for UNIX and UNIX workalike systems is to add
an underscore to the end of the name.

I don't see an underscore in the example you posted, so that might not
be the change made in your case.   Which compiler and operating system
are you using?

Bob Corbett



reply via email to

[Prev in Thread] Current Thread [Next in Thread]