Re: C++ and Fortran - Help linking files
Re: C++ and Fortran - Help linking files
- Subject: Re: C++ and Fortran - Help linking files
- From: David Bourne <email@hidden>
- Date: Fri, 11 Nov 2016 19:11:44 -0700
Jonathan
> On Nov 11, 2016, at 3:54 PM, Jonathan Prescott <email@hidden> wrote:
>
> Based on the code you sent in your e-mail, your C/C++ code would be calling _outText and _otherText, based on the linker errors.
outText and otherText were for an example multi-file Fortran test program that worked. Staying with fortran code seems to be workable using gfortran as the compiler/linker. In fact this evening I was able to compile my 20 file fortran program using gfortran within Xcode. Maybe a big plus for future fortran only programming or I may just stay with a makefile...
> Not sure where the _FF1 and _FR1 came from. Being a Swift newbie, I’m not sure what the ABI conventions at the object code level are, which is what you are matching with the C/C++ conventions. You may need to write a C-wrapper anyway, something like:
>
> void outText()
> {
> _outText();
> }
>
> Again, I’m not sure what link-level conventions Swift uses to generate object code. And, it may differ between macOS/Darwin and Linux.
>
> Jonathan
—
> Found the FR1 and FF1, sorry about that. Point still holds. Based on the linker error, your C/C++ interface to Fortran FR1 and FF1 is _FR1 and _FF1. That is consistent with the experience I had on SGI MIPS compilers, Solaris compilers, and VAX/VMS compilers, as well as BSD compilers. But, it is extremely compiler/linker/OS dependent. No standard conventions are followed.
I tried adding/removing the underscore without success. I think the issue is with the linker definition.
Thanks for the comments. David
> That’s why Ada has its Fortran/C/… interface specifications. Made the application code environment-independent.
>
> Jonathan
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden