DLL questions in CVF example code

DLL questions in CVF example code

I dont know how to compile the CVF example EXAMPLEDLLDLLEXP1 .

The problem I encountered is how I can complie the DLL project which reference subprogram or data of another DLL project and which need a .Lib to complete the Linking?

May be the makefile attached to the example can solve my problem, but I do know nothing about makefile.

I'm sorry to bother u again, steve ;-)

14 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

sombody can help me?!
thanks in advance!

The DLLEXP1 example is more complicated than it ought to be - it illustrates an application where you have two DLLs, each referencing data the other defines. This is an unusual (and not particularly good) situation - normally, there would be a proper nesting of references without circular references. If a programmer who worked for me did something this way, I'd tell them to go back and rewrite it without the circular references.

The trick DLLEXP1 uses, which is in the makefile, is that DLL1 is built twice. The first time it is just compiled and then a lib/def command is run to create an export library (.lib) based on the DLLEXPORT directives in the source. Next, DLL2 is built, linking against the DLL1.LIB that was built in the first step. Third, DLL1 is built again, this time as a complete DLL (creating another DLL1.LIB), and finally, the main program is built.

What are you trying to accomplish?

Steve

Steve - Intel Developer Support

I just want to know what u tell me. thanks a lot!
I will pay attention to the design without circular references.
Why the CVF team provide makefile instead of workspace file?

This example was inherited from Microsoft. Because of the circular reference, it is tricky to make a workspace out of it. I think the best way to do that is to make the compile and library creation of DLL1 (first step) be a custom build step for DLL1.

We need to go through all the examples for the combined product anyway, and we'll take another look at this.

There are generally two types of DLL data sharing people want - one is where each program has its own private copy of the data (which DLLEXP1 demonstrates but adding the circular ref makes it harder to understand), and one where multiple programs on the system share one copy of the data - DLLEXP2 does this, and it could be made into a workspace without too much trouble - just need the /section switch added to the link options.

Steve

Steve - Intel Developer Support

There's another problem with DLLEXP2 example.
I used the command attached with custom.f90, that is,
df custom.f90 /dll /link /section:.data,RWS
and 2 issue came.

1st, error occured unless I place "dfordll.lib" into "D:Documents and Settings". But I'm sure that dfordll.lib is placed in the same dir as dfport.lib. Why the linker specially correlated dfordll.lib with that dir? (the DFVARS.BAT had been taken effect!)
F:DLLDLLEXP2>df custom.f90 /dll /link /section:.data,rws
Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update B)
Copyright 2001 Compaq Computer Corp. All rights reserved.

custom.f90
Microsoft Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/entry:_DllMainCRTStartup@12
/ignore:505
/debugtype:cv
/debug:minimal
/pdb:none
D:DOCUME~1dfordll.lib
msvcrt.lib
dfconsol.lib
dfport.lib
kernel32.lib
/out:custom.dll
/dll
/section:.data,rws
LINK : fatal error LNK1181: cannot open input file "D:DOCUME~1dfordll.lib"

2nd, Why is there no .lib file generated for me with the command running successfully?
F:DLLDLLEXP2>df custom.f90 /dll /link /section:.data,rws
Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update B)
Copyright 2001 Compaq Computer Corp. All rights reserved.

custom.f90
Microsoft Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/entry:_DllMainCRTStartup@12
/ignore:505
/debugtype:cv
/debug:minimal
/pdb:none
D:DOCUME~1dfordll.lib
msvcrt.lib
dfconsol.lib
dfport.lib
kernel32.lib
/out:custom.dll
/dll
/section:.data,rws
LINK : warning LNK4001: no object files specified; libraries used
LINK : warning LNK4068: /MACHINE not specified; defaulting to IX86

thanks again!

The link problem is due to your TEMP folder being in a path with a space in its name and your using an old CVF version. Either upgrade to the current version or change the definition of the TEMP and TMP environment variables (Right click on My Computer, select Properties, Advanced, Environment Variables) to point to an existing folder whose path does not contain a space, for example. C:TEMP

No export library is created if you don't have one or more valid DLLEXPORT directives.

Steve

Steve - Intel Developer Support

My CVF is 6.6B (not old).
My TEMP/TMP user variable is set to "%USERPROFILE%Local SettingsTemp". (is it ok?)

It do has a DLLEXPORT directives. look below
! This F90 program will be compiled into a DLL, and then
! used to link against by two test programs.
! It contains COMMON that will be shared between the two.
!
! To compile this program into a dll that can share this
! common area, use the command:
! df custom.f90 /dll /link /section:.data,RWS
!

block data
common /cb/ i, j
!DEC$ ATTRIBUTES DLLEXPORT :: /cb/
data i,j /6,7/

end

I still have an uncertainty. The DLLEXP2 shows us that prog1 & prog2 share the same common block in custom.dll, is that true? But why I get this result?
F:DLLDLLEXP2progRelease>prog1
Values of I,J before pause:
6 7
Fortran Pause - Enter command or to continue.
prog2
Values of I,J set within PROG2 are:
4 5
Fortran Pause - Enter command or to continue.

Values of I,J after pause:
6 7

the prog2 changed the i,j, but it took no effect in the scope of prog1.

Our forum is slow these days. It always takes me several minute to load next page.

steve, is there a way to set implicit noneb] as default? I hate the implicit type!

If I change the place of directive statement, is it the same?
example:
!DEC$ ATTRIBUTES DLLIMPORT :: /cb/
common /cb/ i, j
integer i,j

common /cb/ i, j
!DEC$ ATTRIBUTES DLLIMPORT :: /cb/
integer i,j

et al

DLLEXP2 needs the /section:.data,RWS switch in the link commnd to share the data.

/warn:declarations will give you an implicit IMPLICIT NONE

The order of directives and declarations shouldn't matter.

Steve

Steve - Intel Developer Support

In Developer Studio IDE, how to set /section:.data,RWS and /warn: please

/section you will have to type in the Common Options box under the Link tab. /warn:declarations is Compilation Diagnostics..Undeclared variables checkbox.

Steve

Steve - Intel Developer Support

I have another question which is discussed before(Write to files in a DLL)
but the solution seemed invalid for my testing.

How can I share a file which opened in calling program in a DLL ?

the testing code is from marcellocattaneo. I did clicked the force file output(equivalent to /force) option(project->setting->link->category(costumize) ),but the result was
Is it open in Main ? T
Is it open in the DLL ? F

!***************************************************
program Cons_OpenFile

!DEC$ ATTRIBUTES DLLIMPORT :: MyProc

implicit none

interface
subroutine MyProc ( ff )
!DEC$ ATTRIBUTES DLLEXPORT :: MyProc
!DEC$ ATTRIBUTES ALIAS: 'MyProc' :: MyProc
use dfwin
integer:: ff
logical:: opn
end subroutine MyProc
end interface

integer:: ff, ios
logical:: opn

ff = 8

open( ff, FILE= 'TestLog.log', &
STATUS='UNKNOWN', IOSTAT=ios )

inquire(ff, OPENED= opn)

print * , 'Is it open in Main ?', opn

call MyProc (ff)

end program

!***************************************************
module dll_readfile

implicit none

contains

subroutine MyProc ( ff )

!DEC$ ATTRIBUTES DLLEXPORT :: MyProc
!DEC$ ATTRIBUTES ALIAS: 'MyProc' :: MyProc
use dfwin
integer:: ff, ret
logical:: opn

inquire(ff, OPENED= opn)

print * , 'Is it open in the DLL ?', opn

end subroutine MyProc

end module dll_readfile

!******************************************************

Message Edited by intel.software.network.support on 12-09-2005 02:14 PM

The main program has to be built to use the DLL form of the run-time library. When you create the executable project, the Fortran project wizard asks if you'll be linking to Fortran DLLs. If you say yes, it changes the project settings appropriately. If you didn't, go to the Libraries dialog and make sure it says the same thing as it does for your DLL project (and it had better be one of the DLL variants.)

If you had to use /force, you've made an error somewhere and need to fix that, as you're just "papering over" the real problem.

Steve

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today