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

link error! need your help

yjyincj
Beginner
1,104 Views
1>------ Build started: Project: learningCenter, Configuration: Debug Win32 ------
1>Compiling with Intel Fortran Compiler 10.1.019 [IA-32]...
1>EX1002.F90
1>Linking...
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol ___kmpc_global_thread_num referenced in function _E1LOCK
1>imsls_err.lib(umach.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1inpl.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1ucs.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1prt.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(n1rgb.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1pop.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1sti.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1stl.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1init.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(dr1ins.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1psh.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1str.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(e1mes.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(r1ins.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(r1int.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(dr1t64.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(dr1t32.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(r1t64.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(r1in32.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(r1t32.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(r1inf.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(rnpoi.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(rnunf.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(drnunf.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsl.lib(r1in64.obj) : error LNK2001: unresolved external symbol ___kmpc_global_thread_num
1>imsls_err.lib(umach.obj) : error LNK2019: unresolved external symbol ___kmpc_threadprivate_cached referenced in function _UMACH
1>imsls_err.lib(e1inpl.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1ucs.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1prt.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(n1rgb.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1pop.obj) : error LNK2001: unresolved external symbol ___kmpc_threadpr ivate_cached
1>imsls_err.lib(e1sti.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1stl.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1init.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(dr1ins.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1psh.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1str.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1mes.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(r1ins.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(r1int.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(dr1t64.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(dr1t32.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(r1t64.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(r1in32.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(r1t32.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(r1inf.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(rnpoi.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(rnunf.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(drnunf.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsl.lib(r1in64.obj) : error LNK2001: unresolved external symbol ___kmpc_threadprivate_cached
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol ___kmpc_critical referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol ___kmpc_flush referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol ___kmpc_end_critical referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol ___kmpc_set_nest_lock referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol _omp_set_nest_lock referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol ___kmpc_unset_nest_lock referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol _omp_unset_nest_lock referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol ___kmpc_init_nest_lock referenced in function _E1LOCK
1>imsls_err.lib(e1lock.obj) : error LNK2019: unresolved external symbol _omp_init_nest_lock referenced in function _E1LOCK
1>Debug/learningCenter.exe : fatal error LNK1120: 11 unresolved externals
1>
1>Build log written to "file://C:VFlearningCenterDebugBuildLog.htm"
1>learningCenter - 61 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

0 Kudos
10 Replies
yjyincj
Beginner
1,104 Views
I found the reason. Now I got one warning.
1>------ Build started: Project: learningCenter, Configuration: Debug Win32 ------
1>Compiling with Intel Fortran Compiler 10.1.019 [IA-32]...
1>EX1002.F90
1>ifort: warning #10234: explicit static allocation of locals specified, overriding OpenMP's implicit auto allocation
1>Linking...
1>Embedding manifest...
1>
1>Build log written to "file://C:VFlearningCenterDebugBuildLog.htm"
1>learningCenter - 0 error(s), 1 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

But I would like to know more about the OpenMP items. what's that? why does it effect the linking process? Thank you.
0 Kudos
TimP
Honored Contributor III
1,104 Views
OpenMP sets the /Qauto option, so that local variables (scalar and array) in threaded regions may be thread local. Static variables would be shared by all threads, creating a race condition if they are modified in a parallel region. If you require the SAVE attribute (for variables or arrays not modified in threaded regions), you should specify it in the source code. I doubt it affects the linking process, but it will certainly have an effect at run time, if you got it wrong.
0 Kudos
yjyincj
Beginner
1,104 Views
I used a Module to define a global array pointer in my code. The LNK error I posted originally came out when I compiled the code. Then I changed the Language/Process OpenMP Directives from disnable to Generate Parallel Code (/Qopenmp). And it ended up with a warning #10234 as I posted.
I am using VS2008. To be frank, I don't know about OpenMP exactly.
0 Kudos
Steven_L_Intel1
Employee
1,104 Views
The warning message you got would seem to have come from some source other than a module variable, since those are not "local". Can you come up with a small but complete example that shows the problem?
0 Kudos
yjyincj
Beginner
1,104 Views
My code is posted bellow. This code is to generate a bunch of
Poisson processes and check if the interval of occurrance
has a exponential distribution. The code is composed of a module,two
subroutine and a main program.
  1. the module defines an array INTERVAL to instore the interval values
  2. IMSL function, OWFRQ, RNPOI, RNUNF are called in the main program.
  3. RANK subroutine sorts numbers
  4. SUBTR does subtraction job.
I still have no idea why the warning comes out, although I have got an exponential distribution result.

module global
include 'link_fnl_static.h'
use OWFRQ_INT
USE RNPOI_INT
USE RNUNF_INT
implicit none
real,pointer::INTERVAL(:)
INTEGER,PARAMETER::NR=1000
end module

PROGRAM CHKPOSN
use global
INTEGER::I,J,NRNUM
INTEGER::LOC,COUNT,M,IR(NR),LAST
INTEGER::IOPT,NOBS
REAL::XLO,XHI,TABLE(100),div(100)
REAL::THETA
REAL,ALLOCATABLE::RANUM(:)
COUNT=0
!read initial parameters
WRITE(*,*)'INPUT THETA'
READ(*,*)THETA
!allocate IR to store poisson numbers
!call RNPOI to generate IR
CALL RANDOM_SEED()
CALL RNPOI(THETA,IR)
!summation of all the poisson number is equal to the
! total occurrances
!allocate INTERVAL to store exponential distributed number
NRNUM=SUM(IR)
ALLOCATE(INTERVAL(NRNUM))
DO I=1,NR
IF(IR(I)==0) CYCLE
COUNT=COUNT+1 !store the number of non-zero IR
ALLOCATE(RANUM(IR(I)))
DO J=1,IR(I)
RANUM(J)=RNUNF()
END DO
CALL RANK(RANUM,IR(I))
CALL SUBTR(RANUM,IR(I))
!determine the location of the first number to be stored in INTERVAL
IF (I == 1) THEN
LOC=1
ELSE
LOC=SUM(IR(:(I-1)))-COUNT+2
END IF
M=IR(I)-1
INTERVAL(LOC:LOC+M-1)=RANUM(:M)
LAST=LOC+M-1 !MARK THE LOCATION OF THE LAST NUMBER
DEALLOCATE(RANUM)
END DO
!CALL owfro to generate frequency table
call OWFRQ(INTERVAL,100,TABLE,NOBS=LAST,IOPT=1,XLO=0.01,XHI=0.99,div=div)
open(unit=10,file='exponum.txt')
write(10,"('midpoints:',100F6.3,/,'COUNTS:',100F10.0)") div,TABLE
close(10)
STOP
END PROGRAM CHKPOSN
!-----------------------------------
!SUBROUTINE RANK
!sort the numbers from smallest to largest using 'exchange methodology'
!---------------------------------
SUBROUTINE rank(X,N)
use global
integer::N,I,J
REAL,INTENT(INOUT)::X(N)
REAL::TEMP
REAL,PARAMETER::DELTA=1.0E-5
DO I=1,N-1
DO J=I+1,N
IF(X(I)-X(J) > DELTA) THEN
TEMP=X(I)
X(I)=X(J)
X(J)=TEMP
END IF
END DO
END DO
return
end subroutine RANK
!----------------------
!SUBROUTINE SUBTR
!subtract a number from the one before it
! save the result to replace the subtracted number
!-----------------------------------
SUBROUTINE SUBTR(X,N)
USE GLOBAL
INTEGER::N
REAL::X(N),TEMP

DO I=1,N-1
TEMP=X(I+1)-X(I)
X(I)=TEMP
END DO
return
END SUBROUTINE SUBTR
0 Kudos
Steven_L_Intel1
Employee
1,104 Views
What compile command did you use. I think the warning is saying that you used /Qsave or some similar option to force static allocation of locals, but OpenMP requires automatic allocation.

If this is the case, remove /Qsave and look closer at how you use variables with OpenMP to make sure that the program behaves properly. Use of the SAVE statement or attribute on selected variables may be needed, but these may interfere with OpenMP.
0 Kudos
yjyincj
Beginner
1,104 Views

MADsblionel:
What compile command did you use. I think the warning is saying that you used /Qsave or some similar option to force static allocation of locals, but OpenMP requires automatic allocation.

If this is the case, remove /Qsave and look closer at how you use variables with OpenMP to make sure that the program behaves properly. Use of the SAVE statement or attribute on selected variables may be needed, but these may interfere with OpenMP.

what do you mean by "compile command"? Yes, I perceived it said some options overwhelm the OpenMP options. But I am not exactly clear with this issue. You know, I usually don't want to use OpenMP technique to run my code because I know nothing about that. But once the OpenMP is disnabled, the compiling crashed. The error information was posted in the first post. Would you help me to find out the reason?

0 Kudos
Steven_L_Intel1
Employee
1,104 Views
Ok, I understand the issue now.

The problem is that IMSL requires access to the OpenMP libraries but Visual Numerics did not include in their list of libraries the one needed to satisfy this requirement.

To fix this, add the following line to your main program (or anywhere that is convenient):

!DEC$ OBJCOMMENT LIB:'libguide.lib'

and rebuild. The errors should go away. Make sure you disable the OpenMP option.

By "compile command" I meant the set of options used to compile a source. In Visual Studio you would see these on the project property page Fortran > Command Line.
0 Kudos
yjyincj
Beginner
1,104 Views
Yeah! It dose works! Thank you.
By the way I found the following statement in the help file:

Ensure that the following project properties are set to ensure correct
operation with the IMSL libraries:
Fortran>Language>Process OpenMP Directives>Generate Parallel Code


The bad news is if I don't know if all the IMSL subroutines need OpenMP.
Would you explain a little bit about this statement?
!DEC$ OBJCOMMENT LIB:'libguide.lib'

0 Kudos
Steven_L_Intel1
Employee
1,104 Views
IMSL uses OpenMP internally and requires that the OpenMP library (libguide) be linked in when you are linking to the static libraries, even if your program does not use OpenMP. If you build against the DLL libraries, no action on your part is needed.

You're familiar with the various 'link_fnl...' INCLUDE files that you use to specify which set of IMSL libraries to link to. These contain a series of !DEC$ OBJCOMMENT directives which tell the compiler to insert instructions to the linker in the object code to bring in the specified library. My recommendation to them had been to add one for libguide.lib, which is the Intel OpenMP library (now called a "legacy" library and I'll talk about that in a moment), but they instead chose to recommend that the user application be built with OpenMP enabled, which has the side effect of bringing in libguide.lib.

The problem with this choice is that enabling OpenMP has other, far-reaching effects, mainly to make the default allocation for ALL variables, scalar and arrays, stack-based. This can cause the program to not run (insufficient stack space) or can lead to wrong results if the program depends on static allocation.

So my advice to users is to ignore the recommendation of enabling OpenMP (unless, of course, you use it yourself), and to add the directive to link against libguide.lib. There are other ways of specifying this, of course, but I find this to be the easiest.

Now about the "legacy" bit - in version 10.1 (or maybe 10.0 - I forget) we introduced a new set of OpenMP libraries referred to as "compatible" or "compat". On Windows, these are compatible with Microsoft's OpenMP calls in Visual C++ so you can now have a mixed-language application combining MS Visual C++ and Intel Fortran using OpenMP. Today, you have to ask for the "compat" library by specifying the option /Qopenmp-lib:compat. In the next major release, the "compat" libraries will be the default and you'll have to specify "legacy" to get the old one (libguide). (On Linux we have the same thing, except there the compatibility is with gcc 4.2.)

The "compat" libraries are actually faster and we'd recommend their use if you can do so. We expect the IMSL that comes with the next major compiler release to use the compat libraries. But for now, it uses the legacy libraries and you must stick with those if using IMSL.
0 Kudos
Reply