Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28602 Discussions

How to link fortran , C++ and C object codes together

richardwong
Beginner
332 Views

I have a C++ program which calls some 'C' functions and calls some Fortran 77 functions pre-defined in a library indirectly.

I can compile the C++ program to generate an object code using icc (Intel compiler 7.1)

But when I use ifc (Intel compiler 7.1) to link the object codes together to create an executable,ifccomplains that it cannot findsome standard'C++' functions (e.g. std::cout)and fails.

Any idea of how to overcome this problem?

0 Kudos
2 Replies
TimP
Honored Contributor III
332 Views
If you use ifc to link a combination of C++ (icc) and Fortran, you will need to append -lcprts (IIRC, for that old compiler with Dinkumware STL). You could poke around with nm in the library directory of you icc installation to find out which .a libraries are required to satisfy missing references. If your C++ were built with -cxxlib_gcc, you would use -lstdc++ instead.
0 Kudos
TimP
Honored Contributor III
332 Views
Maybe it doesn't go without saying, you must somehow avoid conflicts between Fortran and C++ runtime, preferably avoiding any mixing of I/O streams, for example.
0 Kudos
Reply