From: Paul H. <cfu...@ea...> - 2005-09-13 00:55:38
|
I'm learning how to compile Fortran into a DLL and call it from C++. My test DLL is just a tiny Fortran subroutine. File hello.for: SUBROUTINE hello PRINT *,"Hello" END File hello.DEF: LIBRARY hello DESCRIPTION "Fortran DLL to say hello" EXPORTS hello_ I build hello.dll from those files like this: g77 -c hello.for dlltool hello.o -d hello.DEF -D hello -e hello.exp -l hello.lib g77 hello.o hello.exp -shared -o hello.dll The main C++ routine in file main.cpp calls the DLL like this: extern "C" void hello_(void); int main() { hello_(); return 0; } I compile it and link it to the DLL with this line: g++ main.cpp hello.lib All the above works ok. But I also want to try building the DLL to use the stdcall convention. So I compile the Fortran with -mrtd and use this declaration in the C++ source: extern "C" void hello_(void) __attribute__((stdcall)); Now when attempting to link the executable, there's an error message about an undefined reference to hello_@0. Could someone please explain where I'm going wrong? |