Deutsch   English   Français   Italiano  
<vlq8he$3pt22$3@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Lynn McGuire <lynnmcguire5@gmail.com>
Newsgroups: comp.lang.fortran
Subject: Re: nasty link problem with Gfortran and G++ (C++) ???
Date: Thu, 9 Jan 2025 22:43:24 -0600
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <vlq8he$3pt22$3@dont-email.me>
References: <vlk6nb$2cmk4$1@dont-email.me> <vlk97b$2d9j6$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 10 Jan 2025 05:43:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="d83f50e59ecf1c1edebe60519ba86cf5";
	logging-data="3994690"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19LfNcRI3R/1IKxRXN5SWmoHp6FAisdBq8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LZd/gwrgN/2iGg7C7qDeZ259Wd4=
In-Reply-To: <vlk97b$2d9j6$2@dont-email.me>
Content-Language: en-US
Bytes: 3393

On 1/7/2025 4:18 PM, Thomas Koenig wrote:
> Lynn McGuire <lynnmcguire5@gmail.com> schrieb:
>> 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.
> 
> Without having looked at the source code, I suspect
> it is probably something that you are not describing.
> 
> You can look into the object files with any number of utilities,
> for example "nm".  Here's an example:
> 
> subroutine foo
>    external bar
>    integer *8 bar
>    print *,bar(1234)
> end subroutine foo
> 
> Compiling to an object file and running nm on this will show you
> 
>                   U bar_
> 0000000000000000 T foo_
>                   U _gfortran_st_write
>                   U _gfortran_st_write_done
>                   U _gfortran_transfer_integer_write
> 
> which means you have a symbol "foo_" defined, it is a global (hence
> uppercase) symbol in the text section (hence T).  You also have
> several undefined symbols, among them bar_, plus some gfortran
> library routines, so all is fine.
> 
> If you do not find your undefined
>> 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.
> 
> That I would consider highly unlikely.

I cannot get a small code sample with or without a DLL to exhibit the 
problem.  Like I said, I thought it was something related to size of my 
DLL.  And this is the small DLL, only 3 MB.

Thanks,
Lynn