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

'error LNK2019: unresolved external symbol' with IMSL

cgchee
Beginner
1,167 Views

Hello,

Currently I'm using IVF(12.0) with IMSL(7.0).
When I build my project 'SteadyState', a problem occurs as follows;

1>------ Build started: Project: SteadyState_, Configuration: Debug Win32 ------

1>Linking...

1>TauchenMod.obj : error LNK2019: unresolved external symbol _DNORDF referenced in function _TAUCHENMOD_mp_TAUCHENTR

'TauchenTr'calls a function 'dnordf'which is defined in 'numerical_libraries.f90' in IMSL. It's as follows;

module TauchenMod

use numerical_libraries

implicit none

contains

subroutine TauchenTr(mean, sigy, lambday, ygrid, prob)

implicit none

integer :: node, i, j

(.........)

prob(i,1) = dnordf((ygrid(1) - cond_mean + 0.5d0*ystep)/sig)

I think I set the path to IMSL library correctly.
Property=>Fortran=>General : C:\\Program Files\\VNI\\imsl\\fnl700\\winin111i32\\include\\dll into Additional Include Directories.
Property=> Linker=>General: C:\\Program Files\\VNI\\imsl\\fnl700\\winin111i32\\lib into Additional Library Directories.

Can you tell me what's wrong with me?

Happy Holidays.

Chung Gu.

0 Kudos
6 Replies
mecej4
Honored Contributor III
1,167 Views
You have specified the paths to the IMSL Include and Lib directories, but did you specify the IMSL libraries that are to be included in the link step?
0 Kudos
Steven_L_Intel1
Employee
1,167 Views
Add these lines to one of your sources:

include 'link_fnl_static.h'
!DEC$ OBJCOMMENT LIB:'libiomp5md.lib'
0 Kudos
cgchee
Beginner
1,167 Views

Thanks for your reply. But what do you mean by 'specifying the IMSL libraries that are to be included in the link step'? If I didn't do it, how can I do it?

Chung

0 Kudos
cgchee
Beginner
1,167 Views
Adding the above two linesmade another problemas follows;

1>------ Build started: Project: SteadyState_, Configuration: Debug Win32 ------
1>Linking...
1>libcmt.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __call_reportfault already defined in LIBCMTD.lib(invarg.obj)

1>libcmt.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
1>libcmt.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler already defined in LIBCMTD.lib

(...........)
1>Debug/SteadyState.exe : fatal error LNK1169: one or more multiply defined symbols found

1>SteadyState_ - 10 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

However, instead of adding the two lines in the source code, by addingimsl_dll.lib imsls_err.lib into Additional Dependencies in Project-Properties-Linker I could resolve that problem. Anyway, thank you for your help and Happy holidays.

Chung.

0 Kudos
mecej4
Honored Contributor III
1,167 Views
You can run into all sorts of troubles if you blindly follow recommendations without understanding the implications.

USE statements tell the compiler to read .mod files from a default modules directory (and, optionally, a specified list of directories specified through environmental variables and/or command line options), typically to ascertain the proper calling sequence to a library routine, and sometimes to make module variables available to user programs. The compiler has to read all needed module files before it can produce object files from your Fortran source.

The linker must then know (a) where to search for special libraries such as the IMSL libraries, and (b) which special libraries are to be included in the link. The places to search are specified either through the LIB environment variable, or through command line options. The list of special libraries to include in the link step are specified either through the LINK environmental variable, or through command line options.

In your previous attempts, you did all the necessary things except specifying the which list (Item (b) in the previous paragraph).

When you use the VS IDE, there are various option lists that you can plunge through and insert appropriate information.

With the same configuration as in the first post of this thread, add to

Project-Properties-Linker-Input-Additional Dependencies: imsl_dll.lib imsls_err.lib

The alternative approach is to add INCLUDELIB directives to your sources, as Steve suggested to you.
0 Kudos
cgchee
Beginner
1,167 Views
It works. I followed"Project-Properties-Linker-Input-Additional Dependencies: imsl_dll.lib imsls_err.lib"
I really appreicate for your help. Merry Christmas.

Chung.
0 Kudos
Reply