This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Calling g77 FORTRAN code from MSVC 7?


I've searched the web, I've looked at the FAQ. I spent
all day yesterday trying to figure this out myself and
I am close.
I just downloaded the complete cygwin about a month
ago so everything should be pretty recent.

I can call my g77 code (sum.f) from g++ by creating a
dll and calling the dll from g++ code. Hurray! Now I
want to do the same thing from MSVC7.

>From the cygwin/bash command prompt I do:
g77 -c  -mrtd -O2  -o sum.o sum.f
dllwrap -s --export-all --output-def sum.def --def
sum2.def --output-lib sum.lib  --driver-name g77 -o
sum.dll sum.o 

Both sum.def and sum2.def contain the same contents:
; dlltool --base-file
/cygdrive/c/DOCUME~1/ADMINI~1/LOCALS~1/Temp/cc001596.base
--output-exp sum.exp --dllname sum.dll --output-def
sum.def --exclude-symbol=_cygwin_dll_entry@12 --def
sum2.def --output-lib sum.lib
EXPORTS
	avg_ @ 1
	summer_ @ 2

>From the dos (cmd.exe) command prompt, I use the
following commands:


cl main.cpp   /c /MLd /W3 /Gm /GX /ZI /Od /D WIN32 /D
_DEBUG /D _CONSOLE /D _MBCS /FD /GZ /GR /D NOPROMPT
cl main.obj sum.lib /link /out:sum.exe 
/subsystem:console /incremental:yes 

No errors until I run it and get an access violation
when I can my fortran functions.

So then I enhanced main.cpp with the following code:

  HMODULE hLib=LoadLibraryA("c:\\Documents and
Settings\\Administrator\\Desktop\\Examples\\sum\\sum.dll");
  if(hLib){
    cout << "load libary worked!" << endl;
  } else {
    cout << "load library failed!"<< endl;
  }

This dies without an error message. This code works
when I call a C DLL generated with MSVC7, however.

Here is how I declare my functions: 
extern "C"  float summer_(float*, int*);
extern "C"  float avg_(float*, int*);

I tried experiment with __stdcall with no luck.

This should work, right? The whole point of inventing
libtool and dllwrap is to create DLLs instead of unix
style shared object files, correct?

I found an example at the MinGW that demonstrated
calling g77 code from Excel, but this example does not
work with Excel 2002. This tells me that what someone
has done what I am trying to to.

  Thanks,
      Siegfried


	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]