程序功能:点击“Add”调用Fortran编写的动态连接库“ExFor.dll”计算c=a+b
 
Add响应函数:
void ADLG::OnAdd() 
{
    // TODO: Add your control notification handler code here
    this->UpdateData();
    HMODULE hDll=LoadLibraryEx(TEXT("ExFor.dll"),NULL,DONT_RESOLVE_DLL_REFERENCES);
    if(!hDll)
    {
       MessageBox("fail","ERROR",MB_OK);
       return;
    }
    float(_stdcall *proc)(float*,float*);
    proc=(float(_stdcall*)(float*,float*))GetProcAddress(hDll,"ADD");
    if(!proc)
    {
        MessageBox("fail","ERROR",MB_OK);
        FreeLibrary(hDll);
        return;
    }
    m_edit3=proc(&m_edit1,&m_edit2);
    this->UpdateData(false);
    FreeLibrary(hDll);
}
Fortran动态连接库ExFor.dll
function ADD(a,b) result(c)

  !DEC$ ATTRIBUTES DLLEXPORT::Add

real a,b,c

c=a+b
open(1,file='D:\Program\LDLmain\LDL\Debug\output.dat')
write(1,*) c
return
end function ADD  

问题1:调试“ExFor.dll”时,到“open(1,file='D:\Program\LDLmain\LDL\Debug\output.dat')”出现错误。删除语句
open(1,file='D:\Program\LDLmain\LDL\Debug\output.dat')
write(1,*) c
则运行成功
请问如何改写?


 

问题2:重新打开动态连接库工程后,再连接生成“ExFor.dll”时,出现错误如下:

--------------------Configuration: ExFor - Win32 Debug--------------------
Linking...
   Creating library Debug/ExFor.lib and object Debug/ExFor.exp
dfor.lib(DFORMAIN.OBJ) : error LNK2001: unresolved external symbol _MAIN__
Debug/ExFor.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

ExFor.dll - 2 error(s), 0 warning(s)