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

Calling Fortran DLL in Win7

chermeuse
Beginner
1,017 Views
I have created a Fortran DLL under VS2008 in WinXp, and i want to call it from VC++ under VS2008 in Win7 .

But there is a problem: This DLL can not be loaded sucessfully in Win7 machine. The loading funcation used in VC is "Loadlibrary".

Can you help me ?

Thank you.

Jiang Cheng
0 Kudos
8 Replies
mecej4
Honored Contributor III
1,017 Views
Please report the versions of the OS and compilers in full detail, and state whether the DLL in question is 32-bit or 64 bit, and whether the program that fails to load the DLL on Win7 is 32-bit or 64-bit.
0 Kudos
Steven_L_Intel1
Employee
1,017 Views
If you want to use a Fortran DLL on a system where the same version of Visual Studio and Visual Fortran is not installed, you need to install "redistributables" on the target system. You can get the Fortran redistributable from here - you want the .msi ("package"). Install this on the target system and see if that helps.
0 Kudos
chermeuse
Beginner
1,017 Views
OS is Win7 64bit and the DLL was created in XP 32bit. The program that fails to load the dll is on Win7 64bit
0 Kudos
Steven_L_Intel1
Employee
1,017 Views
Doesn't matter. By default, your Fortran DLL is built against DLL libraries so it has DLL dependencies. You can also try changing the "Use run-time library" setting to "Multithreaded" instead of "Multithreaded DLL", but if you're calling from C/C++ I generally recommend against that.
0 Kudos
bmchenry
New Contributor II
1,017 Views
when you say 'fails to load' what error message do you get?
I have not encountered any issues with linking C++ programs with Fortran DLL's from update 3.
can it not find the DLL? (which would be a directory issue)
or does a specific error occur?
be sure to copy the files, or specify the same directory for the build targets, or use
$(SolutionDir)$(ConfigurationName)
as target location for C++ and Fortran in the Solution.

brian
0 Kudos
chermeuse
Beginner
1,017 Views
I used "Loadlibrary" to load the DLL and the returned Hinstance is emety when it fails to load.

I am sure that the directory is right.

Is there any possibility of the uncompatible between the 64bit and the 32bit? Because the DLL was created on

32bit platform and loading DLL was occurred on 64bit platform.

thanks a lot
0 Kudos
chermeuse
Beginner
1,017 Views
i have tried but still exists.

0 Kudos
aagaard
Beginner
1,017 Views
Are you building a 64 or 32 bit application ?
You cannot mix 32 and 64 bit - as far as I know
So if your application is 64 bit, then you cannot load a 32 bit dll
0 Kudos
Reply