Linking multiple languages

Andrew Haley
Mon Sep 2 08:21:00 GMT 2013

On 08/31/2013 07:29 PM, LMH wrote:
> Andrew Haley wrote:
>> On 08/31/2013 03:10 AM, NightStrike wrote:
>>> If I compile c++ code, I am supposed to use g++.  This automatically
>>> does some magic that calling just Gcc would not do. The same with
>>> Fortran code and gfortran.  So my question is which frontend should I
>>> use to link if I have object files from both c++ as well as Fortran,
>>> c, and maybe another language still?
>> You'll probably use gcc but explicitly link in each language's support
>> library.
> You can really do it in whatever way you want. If you have an 
> application with mixed src code, you could compile it as FORTRAN and 
> link to the c library, or compile as c and link to the FORTRAN library. 
> Whether you compile as c or c++ doesn't make any real difference.

That's technically true, but IME in mixed-language build environments it's
probably best to be explicit in the makefiles about what you need.


More information about the Gcc-help mailing list