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.
29282 Discussions

Linking Fortran DLL in Same Solution

swegner
Beginner
592 Views
I'm to create a solution with 2 projects: a Fortran DLL, and a Fortran application which uses functions within that DLL. I've created a simple example to get myself started, but am having trouble linking with the DLL. My build environment is as follows:

Windows XP x64 (SP2)
Visual Studio 2005 (SP1)
Intel Visual Fortran 9.1
Building for x64 platform

Here's the steps I have taken:
-- Created new solution with Intel Fortran DLL project
-- Added new source file:
MODULE DLL_MOD
CONTAINS
SUBROUTINE DLL_PRINT(x)
!DEC$ ATTRIBUTES DLLEXPORT :: DLL_PRINT
INTEGER :: x
WRITE(*,*) x
RETURN
END SUBROUTINE DLL_PRINT
ENDMODULE DLL_MOD
-- Create new Fortran Application project inside current solution
-- Add DLL project as a dependency of new project
-- Add new source file to new project:

PROGRAM EXE_TEST

USE DLL_MOD
IMPLICIT NONE
INTEGER :: a = 1
CALL DLL_PRINT(a)
END PROGRAM EXE_TEST

-- In the project settings of the new project, add the output directory of the DLL project under Fortran > General > Additional Include Directories (this resolved compiler error looking for mod file).

-- In the Configuration Manager, create new solution platform for "x64", creating and selecting new platforms for projects as well.

-- In Tools > Options > Intel Fortran > General, select "x64" under "Target Platform"

When I try to build with this setup, I can build the DLL project, but the application project receives a linking error:

error LNK2019: unresolved external symbol __imp__DLL_MOD_mp_DLL_PRINT referenced in function MAIN__

Using the dumpbin utility, I can see the symbol is being exported. It seems, though, that it is exported under the name "DLL_MOD_mp_DLL_PRINT", but the application is looking for the symbol with a "__imp__" prefix. Does anyone know what the problem could be? I hope I have been thorough enough.
0 Kudos
1 Reply
swegner
Beginner
592 Views
I've resolved this on my own, although I'm not sure where the problem was exactly...

Previously I had installed a trial version of the Visual Fortran 10.0.026 compiler, which was integrated side-by-side with 9.1 in Visual Studio 2005. I uninstalled both compilers, and re-installed an updated version of 9.1. After that everything built just fine.

0 Kudos
Reply