Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

Interoperability of Intel Visual Fortran Compiler

Hello everyone

I am developing an application in Visual Studio 2013, the .Net Solution is integrated with two Projects (Mixed Language), as follows: an INTEL VISUAL FORTRAN Project and a VB.NET Project.

The IVF project has several “Source Files” with f90 language and there must be a transfer from the Source Files to the VB.NET Project
One of the Source Files of the IVF Project has to call a function that is inside an external dll that was generated in the Delphi Application, in this case I only have the dll, I do not have a .lib file

I've been reviewing information for about a week and trying to make the call to this Delphi dll from IVF and I have not found a clear methodology to do this or an example to follow

Questions:

Is it possible what I want to do in my Visual Studio Solution?
If the answer to the previous question is "yes", could you please help me with the statements that I should include within the IVF code?

I appreciate the help

Greetings

ED

 

ED.
0 Kudos
16 Replies
Highlighted
Black Belt

It is quite easy to generate

It is quite easy to generate an import library from a preexisting DLL, with the proper tools. Some linkers can link directly with the DLL without needing an import library. Utilities with names such as MAKEDEF or IMPLIB read the DLL and create a module definition file (*.DEF), which can be processed with the LIB utility to produce an import library.

Alternatively, you can use the DUMPBIN utility on the DLL to produce a list of exported symbols, from which you can create the DEF file.

A related issue is whether the Delphi routines in the DLL are compatible as to calling convention and argument types with the Fortran caller.

0 Kudos
Highlighted
Beginner

Friend

Friend

Well, using Visual StudioTools to generate a module definition file (* .def), then using the "dumbin" utility on the DLL I got a * .lib file that I added to the Fortran Project debug folder; with these steps when compiling the IVF solution does not recognize the Delphi DLL. In fact, I did this before uploading the post to the forum thinking that maybe there was another way to integrate or make the call to the Delphi DLL

I think then that it should be treated as mention of a problem of incompatibility of the Delphi function with the type of convension or argument when calling from fortran

I think then that I will have to discard the use of the DLL of Delphi and try to generate a subroutine the VB.NET that does the same thing that does the DLL of Delphi, hoping that this can be ...

I appreciate the answer

ED.

ED.
0 Kudos
Highlighted
Black Belt

Quote:Eloy D. wrote:with

Eloy D. wrote:
with these steps when compiling the IVF solution does not recognize the Delphi DLL

I don't know what you mean by "does not recognize". In fact, the way the VC linker works is to use only the import libraries at link time. The DLL is not used until you successfully build your EXE and run it. Simply putting the library files into a directory does not tell the linker to use them.

One way is to add these libraries to the Properties:Linker:Input:Additional Dependencies and add the path to the directory containing these libraries to Linker:General:Additional Library Directories. A simpler way is to build at the command line, after modifying %LIB% and specifying the additional libraries to the link command.

0 Kudos
Highlighted
Beginner

Well, what I meant by "does

Well, what I meant by "does not recognize" is that the IVF compiler does not find the dll.
I'll try your suggestion using the option making the respective modifications in the properties window for the compilation directives; I also did an example before so I did not run maybe because I did not have the * .lib file. I will try again
I appreciate the answer

ED.

ED.
0 Kudos
Highlighted
New Contributor II

The compiler does not need

The compiler does not need the DLL, it needs the .lib that tells it how to communicate with the DLL.  When the program executes it needs to be able to locate the DLL, e.g. the location can be in the PATH.

0 Kudos
Highlighted
Beginner

hello

hello

following your last suggestions, how to make the link to the dll serious as shown in the image?

 

Image1.bmp

ED.
0 Kudos
Highlighted
Beginner

in project of IVF implements

in project of IVF implements the following module:

MODULE FILE_OUT

    interface
        subroutine SUB_DELPHI()
            !DEC$ ATTRIBUTES EXTERN :: DLL_DELPHI
        end subroutine       
    end interface
                   
END MODULE


the idea is that having this module later you can call the Delphi dll method from a sourcefile.f90, this could be with the directive:

SUBROUTINE MIXER

!...

USE FILE_OUT

IMPLICIT NONE

!DEC$ ATTRIBUTES DLLIMPORT, STDCALL :: SUB_DELPHI

!...

CALL SUB_DELPHI

!...

END SUBROUTINE MIXER

ED.
0 Kudos
Highlighted
Black Belt

Your usage of the /IMPLIB

Your usage of the /IMPLIB option is incorrect; please read the Microsoft documentation for LINK, where you will find that /IMPLIB is used to give a non-default name the import library when the import library is being created. What you need, on the other hand, is for a previously created import library to be input to the linker. The solution is simple: simply remove the part "/IMPLIB:", leaving just the library name.

0 Kudos
Highlighted

ah, I get it ... you want to

ah, I get it ... you want to automatically load the Delphi dll.

The syntax for that is

!DIR$ OBJCOMMENT LIB: "NameOfYourDelphiIMPLIB.lib"

This will put instructions in the final executable to bring in your dll at runtime.

Then, you'll have to make sure the DLL can be found at runtime.  It needs to be in the same directory as your executable, or on PATH, or in one of the Windows-owned standard directories (not recommended for the average user).

              I hope this helps --

                                         --Lorri

 

0 Kudos
Highlighted
Beginner

mecej

mecej

I have done the suggested and the IVF compiler indicates the error LNK1169: one or more simultaneously defined symbols were found

in effect I have other dortran dlls that are also called within the same SourceFile (in which I want to call the Delphi DLL) ... but I do not understand the cause of this error!

I appreciate the answers

 

ED.
0 Kudos
Highlighted
Beginner

Lorri

Lorri

Following your suggestion add the following line

DIR $ OBJCOMENT LIB: "DLL_DELPHI.lib"

the IVF compiler indicates error # 5082: Syntax error, found IDENTIFIER 'OBJCOMENT'

changing the instruction to

! DIR $ OBJCOMENT LIB: "DLL_DELPHI.lib"

IVF performs compilation without errors but indicates

remark # 5140: Unrecognized directive

anyway i appreciate your suggestion

 

ED.

ED.
0 Kudos
Highlighted
Beginner

Well Friends

Well Friends

I think the solution of projects in mixed language and different calls to internal and external dll's ... is something complex for me that I'm starting with the programming in IVF


I think I should read more theory about it


I appreciate your answers

ED.
0 Kudos
Highlighted
Black Belt

The linker would have given

The linker would have given you specific details of the duplicate symbols, along the lines of "symbol _xyz defined in abc.obj also defined in pqr.obj". You have to collect and deal with all these duplicate symbols, and to do so you will need to know the purpose of each of those symbols. If you use multiple Fortran DLLs, there should be no symbol that is exported by more than one DLL, and there should be no imported symbol that is not defined in any of the DLLs.

In other words, the remedy depends on the details, and you have not provided those details.

0 Kudos
Highlighted
Valued Contributor II

You misspelled OBJCOMMENT!  

You misspelled OBJCOMMENT!

 

0 Kudos
Highlighted
Moderator

Quote:Eloy D. wrote:

Eloy D. wrote:

 

DIR $ OBJCOMENT LIB: "DLL_DELPHI.lib"

the IVF compiler indicates error # 5082: Syntax error, found IDENTIFIER 'OBJCOMENT'

changing the instruction to

! DIR $ OBJCOMENT LIB: "DLL_DELPHI.lib"

ED.

I think OBJCOMENT is spelled wrong.

 Intel Fortran Developer Guide is your friend:

Check https://software.intel.com/en-us/node/679613

Devorah - Intel® Developer Support
0 Kudos
Highlighted
Beginner

 

 

DO and Devorah

you are right

the directive with the correct writing is:

...OBJCOMMENT...

 Thank you

 

ED.
0 Kudos