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

problem linking to IVF static library

rskalgutkar
Beginner
1,373 Views
I am linking a fortran static library to a MSVC DLL. The code compiles just fine and works well too. But when I include a write statement in the fortran code the problems begin. The static library is compiled without a problem as is the C code. However the linker gives me an error about an unreferenced external _for_write_int_fmt. I checked the fortran static library using dumpbin and sure enough _for_write_int_fmt is there as an undefined external symbol.
I have included the Intel...IA32lib folder without any luck, probably because I am not specifying the library to look into for _for_write_int_fmt... Seems like all I have to do is specify the correct library for this code. Any suggestions on how to make this work?
Thanks.
0 Kudos
11 Replies
Steven_L_Intel1
Employee
1,373 Views
There are two ways to do this:

1) Enter the library names in the project properties under Linker, Input

2) Under the properties page Fortran..Libraries, for your library project, set "Disable Default Library Search Rules" to "No". It is set to Yes by defsult so as to not cause complications when linking to other Fortran projects.
0 Kudos
rskalgutkar
Beginner
1,373 Views
Steve,
Thanks! I also found that I need to include %INTEL_FORTRAN%IA32lib as well as ignore libcmt.lib to make it work.
Thanks.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,373 Views
Oh, no -- don't ever "Ignore library". That's the wrong cure. Instead, ensure that Fortran run-time library you link with is of the same type as the C++ run-time library. (For example, debug static<->debug static).Now, it sounds as if your settings for C++/Code Generationare "Multi-threaded" but you linked with IVF library other than "libifcoremt.lib". Instead of ignoring libcmt.lib, change either C++RTL or IVF RTL so that they match (naming conventions are rather obvious -- see "Intel Fortran/C Mixed-Language Programs Overview" page in the IVF help for complete list).
Jugoslav

Message Edited by JugoslavDujic on 11-26-2004 10:07 AM

0 Kudos
rskalgutkar
Beginner
1,373 Views
I have to ignore libc.lib when I create pure Fortran executables too. The IMSL (v. 5.0) documentation says that one should set the runtime libraries to multithreaded and then ignore libc.lib (readme_ia32.txt). If I try compiling using single threaded libraries, I get link errors that __beginthread and __endthread are unresolved external symbols which makes sense.
How do you link specifically to libifcoremt.lib and not libifcore.lib? I looked at my command line information within the .NET IDE and could not find any compiler option that specifially refers to what library touse other than /libs:static /threads which is directing the compiler to use the multithreaded version anyway.
Are you using the command prompt to compile your applications and then specifying libifcoremt.lib at the command line? I will read the IVF documentation that you mentioned.
Thanks for your help,
Rajdeep
0 Kudos
Steven_L_Intel1
Employee
1,373 Views
The IMSL documentation says to use "ignore libraries"? I'll have to get that fixed.

See the section on using IMSL in the 8.1 User's Guide (using libraries chapter.)
0 Kudos
rskalgutkar
Beginner
1,373 Views
My IMSL library comes directly from VNI, not bundled with IVFPro. Could there be a difference between the two versions? I have copied the relevant part of readme_ia32.txt for your reference at the bottom of this email. Look at the last line of step 4.
I have followed the instructions in the IVF 8.1 documentation _exactly_ and still need to ignore libc.lib. :) I set up the options exactly as directed with the default singlethread libraries option unchanged only to get errors that libcmt.lib conflicts with libc.lib. So I ignore libcmt.lib only to get an error that __beginthread and __endthread are unresolved externals.ThenI set the library to multithreaded and remove the libcmt.lib ignore library option. That's when libc.lib starts complaining about procedures already defined in libcmt.lib.
I am starting to wonder if I have a multithread version of the library from VNI? I thought that IVF Pro simply bundles the same library that I have.
Thanks,
Rajdeep

o Using the IMSL Fortran Library from Microsoft Visual Studio .NET 2003

1) Start the Microsoft Visual Studio .NET Developer Environment. Select
Microsoft Visual Studio .NET 2003 from Start-> Programs -> Microsoft
Microsoft Visual Studio .NET 2003
2) If you have not already defined a Solution Workspace for your
application, you must do so before proceeding. Close all Solutions
and choose File -> New -> Blank Solution. Under Project Types,
select Intel Fortran Projects. Under Templates, choose
"Console Application" as the project type, fill in the name of
the project, select the desired location, and click OK. In the
Win32 Application Wizard select Application Settings. Select
Empty Project and Finish.
Select Project -> Add Existing Item and add your Fortran source
code file or for testing you may use imslmp.f90 from
CTT5.5examplesia32f90validate
3) Click on Project -> Properties -> Configuration Properties
Under Fortran General, add CTT5.5includeIA32
to the "Additional Include Directories" list and then click OK.
Under Fortran Floating Point, check that the default setting
for Floating Point Exception Handling is selected. It should
be set to "Produce NaN, signed infinity, and denormal results"
Under Linker General, add CTT5.5libia32
to the "Additional Library Directories" list and then click OK.

Note: If you did not allow Setup to update the System Registry at
installation time, this directory, CTT5.5libia32 ,
must be added to the environment variable PATH prior to starting
Microsoft Visual Studio .NET.
4) Follow step 4a if you wish to link to the dll library. Follow
step 4b if you wish to link to the static library.
a) link to dll
In your Fortran source code, add one of the following header
files in an include statement. For example:
include 'link_f90_dll.h'
The names of the header files are:

link_f90_dll.h - Link options required to link
with the DLL version of the IMSL
Fortran Library.
link_f90_dll_smp.h - Link options required to link
with the DLL version of both the
IMSL Fortran Library and the
Intel MKL Library.
b) link to static
In your Fortran source code, add one of the following header
files in an include statement. For example:
include 'link_f90_static.h'
The names of the header files are:
link_f90_static.h - Link options required to link
with the static version of the
IMSL Fortran Library.
link_f90_static_smp.h - Link options required to link
with the static SMP version of
the IMSL Fortran Library.
link_mpi.h - Link options required to link
with the static version of
the IMSL Fortran Library.
(requires MPI library)
link_mpis.h - Link options required to link
with the static version of
the IMSL Fortran Library.
(uses scalar error handler and requires MPI library)
This can be used when the
application uses MPI but does not require
IMSL routines which use MPI.
link_mpi_smp.h - Link options required to link
with the static SMP version of
the IMSL Fortran Library.
(requires MPI library)
link_mpis_smp.h - Link options required to link
with the static SMP version of
the IMSL Fortran Library.
(uses scalar error handler and requires MPI library)
This can be used when the
application uses MPI but does not require
IMSL routines which use MPI.
Click on Project -> Properties -> Configuration Properties
Under Fortran Libraries, select Runtime Library and then select
Multithreaded
Under Linker Input, add libc to Ignore Specific Library

5) You should now be ready to build the Solution and run the program,
assuming that you have already set up the license file.
0 Kudos
Steven_L_Intel1
Employee
1,373 Views
Hmm - no, that's not the same as comes with IVF Pro.

Steve
0 Kudos
gkchang
Beginner
1,373 Views
Hi,

Right after upgrading IVF to 10.00.0027 with IMSL 6.0, I found that my previous IVF DLL projects with IMSL static linking now cause compling errors with messages such as:
"Error LNK2001: unresolved external symbol_kmpc_global_thread_num" in file "imsl_lib.lib".

When I switch to dynamic linking, these DLL projects then work! Is it happening to anyone?

Cheers
George
0 Kudos
Steven_L_Intel1
Employee
1,373 Views
That is to be expected, and is even sort of documented, but you're forgiven for missing it. In IMSL 6, the libraries are all threaded and require use of the OpenMP libraries. The DLL libraries have that dependency resolved but static libraries do not. Visual Numerics suggests adding the /Qopenmp option but I recommend instead adding libguide.lib to the list of libraries linked in. Ideally, libguide.lib would be included in the list of libraries in the various link_fnl_xxx.h include files. This is something under discussion with VNI.
0 Kudos
gkchang
Beginner
1,373 Views
Thanks a lot, Steve! Adding libguide.lib to the Liner/Input list works. Please keep us posted if VNI would include libguide.lib into their include files.

Also, it would nice if such a change of behavior can be spelled out in the release notes in the future. Thanks again!

Cheers
George
0 Kudos
Steven_L_Intel1
Employee
1,373 Views
It IS in the release notes, but I can understand your missing it. Perhaps I can reword the text to be clearer. It currently says (emphasis in this post, not in the release notes):

For information on how to configure your environment for using the IMSL libraries from either Microsoft Visual Studio or the command line, please read Intel Visual Fortran Compiler Documentation > Building Applications > Using Libraries > Using the IMSL* Mathematical and Statistical Libraries. This information has changed from previous releases.
0 Kudos
Reply