So, I am getting access violations when I have C programs calling static FORTRAN libraries. So I broke the problem down to the simplest form I could to try to isolate the issue. Specifically, the problem only occurs when the FORTRAN library is linked in.
I am using SCEW - Simple C Expat Wrapper SCEW - Simple C Expat Wrapper and Expat http://expat.sourceforge.net/. Within scew there is a sample program called scew_print which reads an XML file and prints it to the screen. My FORTRAN library contains only one subroutine.
SUBROUTINE MULTIPLY (RA, RB, RC)
IMPLICIT NONE
DOUBLE PRECISION RA, RB, RC
RC = RA * RB
RETURN
END
Within scew_print I add:
extern void multiply_();
...
double a, b, c;
a = 2;
b = 2;
c = 4;
multiply_(&a,&b,&c);
Everything compiles and links perfectly. However, only when I have the FORTRAN library call in C does the program crash when trying to run scew_print.
I am using these libraries from PGI to link in MS Visual Studio C 2010.
libpgsse1.lib;libpgsse2.lib;libpgc.lib;libpgmp.lib;pg.lib;libpgf90.lib;libpgf90_rpm1.lib;libpgf902.lib;libpgf90rtl.lib;libpgftnrtl.lib;libnspgc.lib;libcmt.lib
and I have to disable these default libraries
msvcrtd;libcmtd
I have a strong feeling something in the PGI libs is mucking things up.
I will gladly provide a Visual Studio solution with this basic scenario.
Thanks.