Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

problem with write statement in a dll

rskalgutkar
Beginner
923 Views
I have been trying to make the following dll code work in IVF. It works nicely when compiled in CVF. The IVF version crashes Excel with a memory reference error. Somehow the IVF version is trying to talk to memory at 0x00000000. By trial and error I know that the problem is with the write statement below. Why is it creating a problem in IVF but not in CVF?
Thanks, Rajdeep
subroutine MyMessageBox(inval)
!dec$ attributes stdcall, reference, dllexport, alias:'MyMessageBox'::MyMessageBox
use dfwin ! use ifwin in IVF
integer :: iret
real(kind=8), intent(in) :: inval
character(len=32) :: chout
write(chout,'(E15.8,A1)') inval,char(0)
iret=MessageBox(GetActiveWindow(),chout,'MessageBox'C,MB_OK)
return
end subroutine MyMessageBox
0 Kudos
6 Replies
Steven_L_Intel1
Employee
923 Views
I've seen this before. Try changing your Use Run-Time Libraries option when building the DLL to "Single-thread DLL" (not "Debug Single-Thread DLL"). I'd appreciate it if you would report the problem to Intel Support so it can be properly investigated.
0 Kudos
Robert_S_6
Beginner
923 Views
Steve,
Based on our previous discussions,I have foundthat the Intel run-time libraries need to be in the C:windowssystem32 folder. That helped me with my write problem.
Bob
0 Kudos
Steven_L_Intel1
Employee
923 Views
I would not expect an access violation for that reason - rather, the DLL would refuse to load. When you install Intel Fortran, it asks you if you want the environment variables updated. If you say no, then PATH isn't updated to include the location of the DLLs. Microsoft's rules for Windows Installer say that products should not install DLLs to the Windows System folder, but this causes headaches when language run-times are involved.
0 Kudos
rskalgutkar
Beginner
923 Views

Steve,

I will send in my problem to Intel Support so that they can take a look at it. I did what you said, ie use Single thread DLL libraries. Now my DLL is only 5 KB whereas with Multithread libraries it is in the order of 360 KB. Excel refuses to recognize the DLL saying that "File not found" although I know it is there. I did a dumpbin on the single thread dll and I know that the subroutine is being exported.

But here is the real kicker: The above code compiles and works very well in Intel Fortran 7.1!

SoI'll just keep using Intel Fortran 7.1.

Thanks, Rajdeep

0 Kudos
Steven_L_Intel1
Employee
923 Views
See my comment about PATH earlier. But it looks as if you were linking against the static libraries before.
0 Kudos
rskalgutkar
Beginner
923 Views

I uninstalled IVF and reinstalled it to be certain that my PATH variables were updated during the installation. Even so, I still get a very small DLL (5 KB) when I link against the single threaded DLL libraries versus the much larger DLL obtained using multithreaded static libraries (364 KB). Excel refuses to recognize the smaller DLL although I am certain that it is there and I am exporting the subroutine. In fact Excel refuses to recognize either the single or multithreaded DLL versions or even the static single threaded version. Finally the DLL linked against multithreaded static libraries causes Excel to crash.

Yes, you are right that initally the project was linking against the multithreadedstatic libraries. That was the default that the project was set to when I created the project.

Intel's supportfolks are looking into this matter. Until then I'll use Intel Fortran 7.1.

Thanks, Rajdeep
0 Kudos
Reply