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

Help needed for compiling dll

kausi
Beginner
1,284 Views
hi everyone

I am not a programmer and a complete newbie to programming. I used to work with matlab but my friend wanted to create the same controller in fortran so that he could convert it into dll and use it in another software. with some help i created the fortran file. but now i have the problem while compiling.
I use ifort command to compile.

when i provide the command

ifort /dll externalcontroller.f90

it says link not found.
what am i supposed to do
0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,284 Views
Do you have Microsoft Visual C++ 2003, 2005 or 2008 installed? Did you use the "Fortran Build Environment" shortcut under "Start > All Programs > Intel Software Development Tools > Intel Fortran Compiler" to open the command prompt window? What is the complete output of the command window starting with the beginning and through the attempt to build the DLL?

The command you show is the correct way, but something is wrong in your system configuration or the way you established the command environment.
0 Kudos
kausi
Beginner
1,284 Views
i have microsoft visual c++ 2008 express edition installed. I did use the foltran build environment as you said .

the following ids what i got

C:F_Files>ifort externalcontroller.f90
Intel Visual Fortran Compiler for applications running on IA-64, Version 10.1
Build 20080312 Package ID: w_fc_p_10.1.021
Copyright 1985-2008 Intel Corporation. All rights reserved.

ifort: error #10037: could not find ' link'


C:F_Files>ifort /dll externalcontroller.f90
Intel Visual Fortran Compiler for applications running on IA-64, Version 10.1
Build 20080312 Package ID: w_fc_p_10.1.021
Copyright 1985-2008 Intel Corporation. All rights reserved.

ifort: error #10037: could not find ' link'

0 Kudos
TimP
Honored Contributor III
1,284 Views
Did you mean to install the Itanium (IA-64) compiler? Windows X64 is supported by 64-bit Windows for AMD64/Intel64 and the AMD64/X64 SDK option for VS and the Intel64 ifort.
0 Kudos
Steven_L_Intel1
Employee
1,284 Views
To add to what Tim says, Visual C++ Express Edition supports building IA-32 (32-bit) applications only. You will need to install and use the IA-32 Fortrtan compiler.
0 Kudos
kausi
Beginner
1,284 Views
Hi

Thank you for your advice.

I tried it and it created a DLL. but now i have another issue. Thee dll created by i fort causes an error in the program i am trying to use.

It says
Runtime error

R6034
An application has made an attempt to load the C runtime library incorrectly.



My fortran program for the dll is given below and i am trying to export DISCON as the dll file.
! This is a very simple example of an external controller DLL written in FORTRAN which simply causes
! a step change in pitch position demand.
! If the pitch actuator cannot accept a pitch position demand, an error message is returned to Bladed.
! A simple example of logging output is also included.

SUBROUTINE DISCON (avrSWAP, aviFAIL, accINFILE, avcOUTNAME, avcMSG)
IMPLICIT NONE

!Compiler specific: Tell the complier that this routine is the entry point for the DLL
!The next line is for the case of the Digital Visual Fortran compiler
!DEC$ ATTRIBUTES DLLEXPORT, ALIAS:'DISCON' :: DISCON

!Arguments
REAL :: avrSWAP(*)
INTEGER :: aviFAIL
INTEGER*1 :: accINFILE(*), avcOUTNAME(*), avcMSG(*)

!Other declarations
INTEGER :: iStatus
INTEGER, SAVE :: iDone
REAL, SAVE :: rPitchDemand

CALL CHAR2INT(' ',avcMsg)

iStatus = NINT(avrSwap(1))
!Initialise
IF (iStatus .EQ. 0) THEN
!Initialise pitch demand to current pitch angle
rPitchDemand = avrSWAP(4)
!This is also where you could read in any user-defined data from accInFile
ENDIF

!Return demanded variables
!Note: previous values can be used before they updated, to simulate a one-sample delay
IF (NINT(avrSwap(10)) .EQ. 0) THEN
avrSWAP(42) = rPitchDemand
avrSWAP(43) = rPitchDemand
avrSWAP(44) = rPitchDemand
avrSWAP(45) = rPitchDemand
ELSE
CALL CHAR2INT('This simple DLL needs pitch position actuator',avcMsg)
aviFail = -1
ENDIF

!Main calculation
IF (aviFail >= 0) THEN
!Just a 1-degree step change in pitch position demand at 10 seconds
IF (iStatus .EQ. 0) iDone = 0
IF (avrSWAP(2) .GE. 10.0 .AND. iDone .EQ. 0) THEN
rPitchDemand = rPitchDemand + 0.017453
iDone = 1
ENDIF
!Logging output
CALL CHAR2INT('Pitch demand:A;',avcOUTNAME)
avrSWAP(NINT(avrSWAP(63))) = rPitchDemand
avrSWAP(65) = 1.0
ENDIF

RETURN
END

!==============================================================================================
!==============================================================================================

SUBROUTINE CHAR2INT(accString,avi1Int)
IMPLICIT NONE
CHARACTER*(*) accString
INTEGER*1 avi1Int(*)
INTEGER I
DO I = 1,LEN_TRIM(accString)
avi1Int(I) = ICHAR(accString(I:I))
ENDDO
avi1Int(LEN_TRIM(accString)+1) = 0
RETURN
END




0 Kudos
TimP
Honored Contributor III
1,284 Views
I just saw the announcement of "the brand new Visual Studio Express Editions." It says clearly on the download web page C++ is for 32-bit native code only, as Steve said (unlike 2005 express). No wonder I had difficulty getting the earlier 2008 express to play with X64 SDK. Reminds me of Steve's favorite crack about my old home town.
As to the latest question, with 2005 Express, it was recommended to add the (32-bit) psdk to support making .dll. There are posts on microsoft forums suggesting that sdk components may have to be added to 2008 Express as well for this purpose.
0 Kudos
Steven_L_Intel1
Employee
1,284 Views
VC++ 2008 Express does not require a separate PSDK.
0 Kudos
Steven_L_Intel1
Employee
1,284 Views
kausi, how are you building this DLL (what options), and what type of program are you using it with?
0 Kudos
Reply