| Deutsch English Français Italiano |
|
<vlkagh$2dm6v$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu>
Newsgroups: comp.lang.fortran
Subject: Re: nasty link problem with Gfortran and G++ (C++) ???
Date: Tue, 7 Jan 2025 22:40:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <vlkagh$2dm6v$1@dont-email.me>
References: <vlk6nb$2cmk4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 07 Jan 2025 23:40:18 +0100 (CET)
Injection-Info: dont-email.me; posting-host="d1e8d174d51b42efb3a122f5b13a8798";
logging-data="2545887"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wnjViiVSbvD+eJfW1oAh1"
User-Agent: Pan/0.145 (Duplicitous mercenary valetism; d7e168a
git.gnome.org/pan2)
Cancel-Lock: sha1:K6sLeX+vk7SMloW11qbhmahjGSQ=
Bytes: 2705
On Tue, 07 Jan 2025 15:35:38 -0600, Lynn McGuire wrote:
> I just ran into a nasty problem with GFortran and G++ (C++). Probably
> not a bug ??? I am using GCC 14.1.
>
> I have a lot of code in C++ (over 100,000 lines). I have 750,000 lines
> of code in GFortran. I have to extern "C" this code in C++ to make it
> callable by GFortran code.
>
> I missed declaring a couple of C++ functions as extern "C" which means
> that they kept their C++ mangled link names. But these C++ functions
> were declared as integer*8 and external in the GFortran code (old F77
> code).
>
> So, the GCC linker did not report to me that it did not have a link for
> the G++ functions. This may be a bug, I am not sure.
>
> When I ran the program, the C++ functions were not called by the
> GFortran code. Instead, the GFortran code treated the C++ functions as
> integer*8 scalar variables.
>
> If needful, I can probably put together a small code sample that
> exhibits the problem. Maybe. It could be that the size of my code
> affects the GCC linker.
>
> I removed the Gfortran code "external" keywords, extern "C" the C++
> functions, added the C++ function to my module list, and got a working
> link.
Need to see some actual code.
% cat > foo.c
int
foo(void)
{
return (1);
}
% gcc14 -c foo.c
% nm foo.o
0000000000000000 T foo
% g++14 -c foo.c
% nm foo.o
0000000000000000 T _Z3foov
% cat > foo.f90
integer*8 function foo()
foo = 1
end
% gfortran14 -c foo.f90
% nm foo.o
0000000000000000 T foo_
So, with gcc, you get the symbol foo. With g++, you get the mangled
named _Z3foov. With gfortran, you get foo_.
--
steve