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

Have DLL but no LIB

fbalderasintel
1,163 Views

I dont often create a new Fortran project but when I did, I made a DLL, it compiled and linked
but did not generate a .lib file.

I have the module statement:
module K3_NN_Utilities

and the DLLEXPORT statements:
DEC$ ATTRIBUTES DLLEXPORT, ALIAS: 'WriteSignalToFile' :: WriteSignalToFileDEC$

and the properties shows that a LIB should be created:

/OUT:"C:\\agr_dev\\Ver1.0\\K3_NN_Utilities\\K3_NN_Utilities\\x64\\Debug\\K3_NN_Utilities.dll" /VERBOSE /NOLOGO /MANIFEST /MANIFESTFILE:"C:\\agr_dev\\Ver1.0\\K3_NN_Utilities\\K3_NN_Utilities\\x64\\Debug\\K3_NN_Utilities.dll.intermediate.manifest" /DEBUG /PDB:"C:\\agr_dev\\Ver1.0\\K3_NN_Utilities\\K3_NN_Utilities\\x64\\Debug\\K3_NN_Utilities.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"C:\\agr_dev\\Ver1.0\\K3_NN_Utilities\\K3_NN_Utilities\\x64\\Debug\\K3_NN_Utilities.lib" /DLL

What is it that triggers a LIB file to be created ?

3 Replies
fbalderasintel
1,163 Views
I found the error of my ways but not sure why this works this way:

subroutine F_ReadSignalDataFromFile(KDDMetaData)

!DEC$ ATTRIBUTES DLLEXPORT, ALIAS: 'ReadSignalDataFromFile' :: ReadSignalDataFromFile

The subroutine name was NOT the same as the DLLEXPORT name.
No error was generated but no *.lib was create either.

Changed DLLEXPORT to match subroutine and suddenly the *.lib file was created.

0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
1,163 Views
The option /DLL on the command line and is the option that causes the .lib to be created. It is implied by creating a Dynamic Link Project. Please see this excerpt from the documentation.

------

Wendy

Attaching or including files in a post



Building Dynamic-Link Libraries

When you first create a DLL, you follow the general steps described in Creating a New Project. Select Fortran Dynamic-Link Library as the project type.

To debug a DLL, you must use a main program that calls the library routines (or references the data). From the Project Property Pages dialog box, choose the Debugging category. A dialog box is available for you to specify the executable for a debug session.

To build the DLL from the Microsoft integrated development environment (IDE):


  1. A Fortran DLL project is created like any other project, but you must specify Dynamic-Link Library as the project type (see Creating a New Project.).

  2. Add files to your Fortran DLL project. Include the DLL Fortran source that exports procedures or data as a file in your project.

  3. If your DLL exports data, consistently specify the project settings options in the Fortran Data compiler option category for both the DLL and any image that references the DLL's exported data. In the Fortran Data compiler option category, specify the appropriate values for Common Element Alignment (common block data) and Structure Member Alignment (structures in a module). This sets the /align option, which specifies whether padding is needed to ensure that exported data items are naturally aligned.

    For example, in the case of a common blOck containing four-byte variables, you might:

    • Open the appropriate solution and select the project in the Solution View.

    • From the Project>Properties, select the Fortran category.

    • Select Data.

    • In the Common Element Alignment box, select 4 Bytes.

  4. If you need to specify linker options, use the Linker category of the Project Property Pages dialog box.

  5. Build your Fortran DLL project.

    The IDE automatically selects the correct linker instructions for loading the proper run-time library routines (located in a DLL themselves). Your DLL is created as a multithread-enabled library. An import library (.LIB) is created for use when you link images that reference the DLL.

To build the DLL from the command line:


  1. If you build a DLL from the command line or use a makefile, you must specify the /dll option. For example, if the Fortran DLL source code is in the file f90arr.f90, use the following command line:

    ifort /dll f90arr.f90

    This command creates:

    • A DLL named f90arr.dll.

    • An import library, f90arr.lib, that you must link with applications that call your DLL.

    If you also specify /exe:file or /link /out:file, the file name you specify is used for a .DLL rather than an .EXE file (the default file extension becomes projectname.DLL instead of projectname.EXE)

    The /dll option selects, as the default, the DLL run-time libraries to support multithreaded operation.

  2. If your DLL will export data, the procedures must be compiled and linked consistently. Consistently use the same /align option for the DLL export procedure and the application that references (imports) it. The goal is to specify padding to ensure that exported data items are naturally aligned, including common block data items and structure element alignment (structures in a module).

  3. If you need to specify linker options, place them after the /link option on the ifort command line.

  4. Build the application. For example, if your DLL exports a common block containing four-byte variables, you might use the following command line (specify the /dll option):

0 Kudos
Steven_L_Intel1
Employee
1,163 Views
However, as was found, a proper DLLEXPORT directive must also be present in order for the .LIB to be created.
Reply