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

Linking Fortran Library Without IFV

smedvedoff
Beginner
806 Views

We intend to build a Fortran libraryusing IVF (could be static or a DLL, but we prefer static). We would like to link the library intoa C++ program. The machine on which the C++ program will be built does not have IVF installed, only Visual C++. Will this work, or could there be unresolved references to other IVF libraries from within our Fortran library? Is there a way to make this work without installing IVF on the C++ build machine?

Thanks,

Steve

0 Kudos
4 Replies
Steven_L_Intel1
Employee
806 Views

You will need to also distribute one or more .lib files from the compiler's /Lib folder. All of them, I think, are redistributable. There is a file fredist.txt in the compiler Docs folder which lists all of the redistributable files.

By default, when you build in Visual Studio, the option "Disable Default Library Search Rules" is set to Yes. You should change this to No (under Libraries.) Build your library in a Release configuration.

Now open a Fortran Build Environment command window, set default (cd) to the folder containing one of the .obj files from your library and type the command:

dumpbin -directives filename.obj

where "filename.obj" is the name of the object file. You will see output that looks like this:

Dump of file t.obj

File Type: COFF OBJECT

Linker Directives
-----------------
-defaultlib:ifconsol
-defaultlib:libifcore
-defaultlib:libifport
-defaultlib:libm
-defaultlib:LIBC
-defaultlib:libirc
-defaultlib:OLDNAMES

The list will be repeated twice. Find all the names listed here that are in the Fortran compiler's /Lib folder and include those with your library. Instuct the user to add the folder containing these libraries to the library search path.

Note that you may run into difficulties with Visual C++ such as: 1) VC2005 does not provide libc, so you need to build your library specifying the "Multithreaded" libraries at least, 2) unlike Fortran, a library built for one library style (static vs. DLL, multithread vs. single-thread) can't be used with other library styles.

Make sure you test thoroughly.

0 Kudos
anthonyrichards
New Contributor III
806 Views
I am curious. I thought that the point of a static library was that it was self-contained and did not require any other LIBs's or DLL's to be loaded for it to work? That is, when building it, I thought that all required 'OBJ'sare added to it when it is built, leaving no unsatisfied references outstanding? Where have I got it wrong?
0 Kudos
Steven_L_Intel1
Employee
806 Views

Yes, you got it wrong. A static library is no more than a collection of the .obj files with NO external references resolved. To use it, you need to also have available, at link time, objects or libraries which satisfy any external references made from within the library. In the case of Fortran code, this usually means the compiler-supplied run-time libraries.

You may be thinking of "static linking" where you tell the linker to build everything into the executable and not rely on DLLs.

0 Kudos
smedvedoff
Beginner
806 Views

Steve,

Thank you very much for the great information! This will help us a lot.

- Steve

0 Kudos
Reply