Calling C++ DLL from FORTRAN ... Application failed to initialize properly
- From: "diverbeard" <jason.beard@xxxxxx>
- Date: 14 Jul 2006 08:15:45 -0700
I have this dll that I wrote in VC++.NET. I've exported some functions
that I know work when called from C++, VB, VBA, HTML (when I regasm(ed)
it). So it works ... but they want me to call it from FORTRAN, writen
in Intel Fortran. When I try to run the fortran code, I get
"Application failed to initialize properly (0xc0000142) Click on OK to
terminate the program"
Here's what I have ...
In my *.h file I have ...
extern "C"
{
__declspec(dllimport) void __stdcall IterateInputFile(String*);
__declspec(dllimport) void __stdcall IterateInputArray(double*,
double*);
}
In my *.cpp file I have ...
void __stdcall IterateInputFile(String* FilePath)
{
STWT::CSTWT* ws = __gc new STWT::CSTWT();
ws->Iterate1(FilePath);
FilePath = FilePath->Replace(S".xml",S".out.xml");
ws->OnFileSaveXml(FilePath);
}
void __stdcall IterateInputArray(double* InputArray, double*
OutputArray)
{
STWT::CSTWT* ws = __gc new STWT::CSTWT();
ws->Iterate2(InputArray);
ws->PopulateOutputArray(&OutputArray[0]);
}
in my FORTRAN project settings ....
Additional Dependancies = "$(OUTDIR)/STWT.lib" (the lib and dll is
located with the f90 exe file)
and .. in my *.f90 file, I have ....
program STWT_FORTRAN
implicit none
REAL *8 Input(92)
REAL *8 Output(56)
character(len=256) FileName
interface
subroutine IterateInputArray(InputArray,OutputArray)
!DEC$ ATTRIBUTES STDCALL, DLLIMPORT, alias: "_IterateInputArray@8" ::
IterateInputArray
REAL *8 InputArray(92)
REAL *8 OutputArray(56)
end subroutine IterateInputArray
subroutine IterateInputFile(InputFile)
!DEC$ ATTRIBUTES STDCALL, DLLIMPORT, alias: "_IterateInputFile@4" ::
IterateInputFile
character(len=256) :: InputFile
end subroutine IterateInputFile
end interface
print *, 'Hello World'
FileName = "D:\\test.stwt.xml"
call IterateInputFile(FileName)
print *, 'Good Bye, Cruel World!'
end program STWT_FORTRAN
*****************
When I run the exe, I get the "Application failed to initialize
properly (0xc0000142) Click on OK to terminate the program" error.
Other behaviors are ...
1) When I comment out the "call IterateInputFile(FileName)" ... the
code runs and I get the console messages.
2) When I run in debug mode, the code fails before reaching the "hello
world" and throws me into "malloc.c" in the void * __cdecl
_heap_alloc_base (size_t size) function.
Any clue?
Thanks,
Jason
.
- Follow-Ups:
- Prev by Date: Re: Need help with large file reading and writing.
- Next by Date: Re: Calling C++ DLL from FORTRAN ... Application failed to initialize properly
- Previous by thread: gfortran/g77 ld problem: undefined references
- Next by thread: Re: Calling C++ DLL from FORTRAN ... Application failed to initialize properly
- Index(es):
Relevant Pages
|