Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Call dll from C++

khjavaid1
Beginner
783 Views

and the Fortran dll is
Code:
subroutine aFunc(aNum)

real , intent(inout) :: aNum

!

!DEC$ATTRIBUTES dllexport :: aFunc

!DEC$ATTRIBUTES DEFAULT, DECORATE,C,REFERENCE, ALIAS: 'aFunc' :: aFunc

!

 integer n

 open (unit = 6, file = "TestFile.txt", status ='new') 

 n=587

 write (6,*) "This is a number ", n, " :" 

 close (6) 

 

aNum    = aNum*aNum

end subroutine aFunc
This works fine if the file-open bit is commented out.
The error is only during run-time. I get an error dialog box saying libifcoremdd.dll is not a valid windows image.
I'm using IVF 9.0 and C++ in VS.NET.
Any suggestions greatfully received.
Kashif
0 Kudos
4 Replies
Steven_L_Intel1
Employee
783 Views
Make sure that the PATH environment variable includes the path to the Intel Fortran IA32/lib folder.

Removing the OPEN eliminates calls to the run-time library, thus hiding the problem.
0 Kudos
khjavaid1
Beginner
783 Views
Hi, I've changed the path to the one you mentioned but still i get the same error. The exact error isc:Program FilesIntelCompilerFortran9.0EM64TBinlibifcoremd.dll is not a valid windows image.
I was having the same problem just outputting a number from the dll in C++ but I resolved this by adding DECORATE to the attributes list.
0 Kudos
Steven_L_Intel1
Employee
783 Views
You are doing this on a 32-bit system? I'm guessing that you installed the EM64T compiler and checked the box to update system environment variables. Normally that's a good thing, but if you do it on an IA-32 system, that means that Windows will find the EM64T DLLs before the IA-32.

Remove any EM64T paths in PATH and make sure the IA32LIB path is there.
0 Kudos
khjavaid1
Beginner
783 Views
Steve,
Thanks very much for your help, it all works fine now.
I will now try and do this in C# (eek!).
Kashif
0 Kudos
Reply