Chong Yidong wrote:
Leaving out the C++ code, here is the simplest example of my problem: 1. Make a file Solver.f90 containing: PROGRAM Solver INTEGER :: foo END PROGRAM Solver 2. gfortran -c Solver.f90
Alternatively, I can try with the -lgfortran flag: 4. g++ Solver.o -lgfortran /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/crt1.o: In function `_start': /build/buildd/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main' collect2: ld returned 1 exit status
As you don't even show an inter-language call, there's little here to comment on, except that it makes no sense so far to use anything but gfortran. If you call a C++ function when using a Fortran main PROGRAM, probably using iso C interop and extern "C", appending -lstdc++ should take care of the standard libraries.
If you had a C++ or C main(), your alternative 4 might make sense.