Subject: Re: CCL:How to call a C++ program from C?

From: Jochen <[email-masked]>
Date: Thu, 30 Sep 1999 09:34:04 +0200

On Mit, 29 Sep 1999 [email-masked] wrote:
>> I have a big program which is written in C and Fortran, but mainly in C.
>> The author compile each module by their own compiler ( cc and f77 on SGI) 
>> and link them by f77.
>> 
>> Now I have another C++ program (still others) and want incorporate it 
>> into the previous big program.

>The reason for this problem is that both C++ and Fortran program often
>need specific initialization code that is added during linking. An
>added complication with C++ is name mangling (the compiler must create
>unique names for overloaded functions etc.), but there are ways around
>that.

Hi Konrad,

you are right - as usual :-)

Many times you can resolve the explained problems by incremental linkage
(like ld -r), though.
So you link all your FORTRAN code into one big object file using the
FORTRAN compiler as linker driver, analogous the C++ code using the C++
linker driver. Then you link these into the final exectuable.
The only remaining problem I ever encountered is some trouble about a
duplicate or no main function.

-- Jochen
        Heinrich-Heine-Universität, Institut für Physikalische Chemie I
        Universitätsstr. 1, Geb. 26.43.02.29, 40225 Düsseldorf, Germany
phone 02118113681 fax 02118115195  --  www-public.rz.uni-duesseldorf.de/~jochen
[email-masked] -- [email-masked] -- [email-masked]