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

Building Win32 Platform apps from 64 bit Platform

halwachs
Beginner
1,840 Views

I have an application that calls three Fortran DLLs and one C++ DLL. This app (and the supporting DLLs) compiles, links and runs successfully on the 64 bit platform (Vista64) in both Platform: x64 and Platform: Win32IVF modes.

When I copy the application (and the 32 bitruntime .libs) to a 32bit platform (Vista32) it fails to run. I have checked the tools >> options >>IVF compilers selections and the selected compiler and libraries are set up correctly for the two platforms.

When I run "Dependency Walker" on the application it shows that the application and DLLs I create are x86 BUT the runtime support libraries [libifcoremd, libifportmd,libmmd]are show as x64. This tells me that at runtime the application will be looking for and attempting to use the 64bit version of the three runtime libraries -- which is not what is loaded on the target machine.

What am I missing here ?
Thanks -- Tom

0 Kudos
9 Replies
Steven_L_Intel1
Employee
1,840 Views
The problem is that the install on an x64 system adds only the x64 run-time DLLs to PATH. At the time, we (actually, I'll take the blame for this) believed that to be correct as it was thought that having 32-bit DLLs of the same name on PATH could prevent 64-bit apps from running.

It turns out that Windows is smarter than that and skips DLLs for the "wrong" architecture (at least it does this on a 64-bit system - not on a 32-bit system.)

The workaround is to add the 32-bit DLLs to PATH. RIght click on My Computer, select Properties, Advanced, Environment Variables. Under system variables, select PATH and click Edit. Add at the end of the path:

;%IFORT_COMPILER11%binia32

and click OK, OK, OK. (Don't forget the leading semicolon.)

We will fix this in a future update.
0 Kudos
halwachs
Beginner
1,840 Views
The problem is that the install on an x64 system adds only the x64 run-time DLLs to PATH. At the time, we (actually, I'll take the blame for this) believed that to be correct as it was thought that having 32-bit DLLs of the same name on PATH could prevent 64-bit apps from running.

It turns out that Windows is smarter than that and skips DLLs for the "wrong" architecture (at least it does this on a 64-bit system - not on a 32-bit system.)

The workaround is to add the 32-bit DLLs to PATH. RIght click on My Computer, select Properties, Advanced, Environment Variables. Under system variables, select PATH and click Edit. Add at the end of the path:

;%IFORT_COMPILER11%binia32

and click OK, OK, OK. (Don't forget the leading semicolon.)

We will fix this in a future update.

Steve,
Thank you for the prompt response. Unfortunately, your suggested solution did not solve the problem. Dependency Walker still shows that my EXE and DLLs require the 64 bit run-time support dlls and the exe fails to load on the 32 bit machine.

I would think that the link step is where I need to have the associated 32bit run-time .libfor the linker to get it right. As it is now, the linker appears topick up the 64bit .lib for the three run-time dlls [libifcoremd, libifportmd and libmmd].

Tom
0 Kudos
Steven_L_Intel1
Employee
1,840 Views
Tom,

I'm sorry, I misread your post. You said you were copying the EXE to a 32-bit system and I thought you were running it on the x64 system.

Did you build the project as a Win32 platform configuration? It doesn't sound like you did.
0 Kudos
halwachs
Beginner
1,840 Views
Tom,

I'm sorry, I misread your post. You said you were copying the EXE to a 32-bit system and I thought you were running it on the x64 system.

Did you build the project as a Win32 platform configuration? It doesn't sound like you did.

Steve,
I built the EXE and my three Fortran DLLs and one C++ DLL using the Win32 Platform -- checked this several times. The EXE and DLLs function perfectly on the x64 system in both platform configurations [x64 and Win32]. It is only when I try to run on a 32-bit system the the EXE fails to load [exception error].

When I check the 32-bit EXE and 32-bit DLLs with Dependency Walker all dependencies are 32-bit EXCEPT the libifcoremd, libifportmd and libmmd which are reported as x64.

I have tried explicity adding the 32-bit libs to the import link step -- same results. Tried excluding the 64-bit libs in the link -- same results.

When I build the EXEand DLL on the 32-bit machine [same version of the compiler and VS] -- all is well. [and in case anyone is wondering -- yes I have multiple licenses!]

Thank you,
Tom
0 Kudos
Steven_L_Intel1
Employee
1,840 Views
In this case, I don't trust Dependency Walker. It is finding the 64-bit run-time DLLs in PATH. If you want to test this:

  1. Start > All Programs > Intel Software Development Tools > Intel Visual Fortran Compiler 11.x.xxx > Build Environment for applications running on IA-32
  2. From this command prompt, run Dependency Walker
  3. In DW, open your EXE.
There's nothing in the EXE itself that forces a 64-bit version of the Fortran DLLs to be loaded, it's just using PATH.

If you are running the program on a 32-bit system, that system needs to have either Fortran installed or the IA-32 redistributable package, which you can download from the Intel Registration Center.
0 Kudos
halwachs
Beginner
1,840 Views
In this case, I don't trust Dependency Walker. It is finding the 64-bit run-time DLLs in PATH. If you want to test this:

  1. Start > All Programs > Intel Software Development Tools > Intel Visual Fortran Compiler 11.x.xxx > Build Environment for applications running on IA-32
  2. From this command prompt, run Dependency Walker
  3. In DW, open your EXE.
There's nothing in the EXE itself that forces a 64-bit version of the Fortran DLLs to be loaded, it's just using PATH.

If you are running the program on a 32-bit system, that system needs to have either Fortran installed or the IA-32 redistributable package, which you can download from the Intel Registration Center.

Steve,
Issue resolved by excluding MSVCRT library in the link step for the FORTRAN DLLs vice excluding LIBCMT. Not exactly sure how (nor why) this enable the ability to run this code on a 32-bit machine after building it on a 64-bit machine. Bothx64 and Win32 builds work fine on the 64bit machine they are compiled and linked on with excluding LIBCMT on the DLL link step.

Thank you,
Tom
0 Kudos
Steven_L_Intel1
Employee
1,840 Views
Hmm - if you were linking to MSVCRT, then it would have been required to have the exact same version of the Visual C++ run-time redistributables on the 32-bit system. I realize now that you never said how it "fails to run" - what was the error message?
0 Kudos
halwachs
Beginner
1,840 Views
Hmm - if you were linking to MSVCRT, then it would have been required to have the exact same version of the Visual C++ run-time redistributables on the 32-bit system. I realize now that you never said how it "fails to run" - what was the error message?

Steve,
The application "failed to run" with an exception immediately at launch. The windows event log is pasted below.

Faulting application sails4.exe, version 0.0.0.0, time stamp 0x4a5e6185, faulting module ntdll.dll, version 6.0.6001.18000, time stamp 0x4791a7a6, exception code 0xc0150002, fault offset 0x00009cac, process id 0x1ecc, application start time 0x01ca05a51c99fd61.

Tom
0 Kudos
Steven_L_Intel1
Employee
1,840 Views
Ok - that's "the application failed to initialize properly" and is almost certainly due to not having the matching MSVCRT version on your 32-bit system.
0 Kudos
Reply