Fatal error LNK1120: 2 unresolved externals

  • Thread starter Thread starter nnnnn
  • Start date Start date
  • Tags Tags
    Error
Click For Summary
The discussion centers around a Fortran90 program encountering linker errors during compilation, specifically unresolved external symbols for the functions "FERMI" and the array "A_INTEGRAL." The user describes the context of the program, which involves numerical integration using a Simpson's rule subroutine and a function named "fermi." The errors indicate that the linker cannot find the definitions for these symbols, suggesting potential issues with the configuration or inclusion of source files in the project. The advice given emphasizes checking that all relevant source files are included in the configuration to resolve the linker errors.
nnnnn
Messages
5
Reaction score
0
********************************************************
Hi , dear friends;
May you please kindly help me with this problem .?
Running my program (fortran90 in compaq visual fortran.6..) leads to this
messages:

((( Linking...
simpson-3.obj : error LNK2001: unresolved external symbol _FERMI@8
simpson-3.obj : error LNK2001: unresolved external symbol _A_INTEGRAL@4
Debug/simpson-3.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe. )))
" FERMI " is a function which is used in my program( it is called in the subroutin) .And
" A_INTEGRAL " is a one dimensional array.
What do you suggest ?? I copy the program here (if it helps) .

Best Regards
N. M.
--------------------------------------------------------------------------------------------
----------------------------------
-------------------
program INTEG_3Ghaneh

real(8),parameter ::Pi=3.14
real(8),parameter ::Temp=1
REAL(8) ::a,b
Integer :: n !n : an even number
integer :: i,j,i1,i2,i3
real(8) :: NN,mo
complex(8),parameter :: ii = (0, 1)

n = 20
a =-10
b = 10
mo= 1

CALL Simpson(n,a,b)
open(unit=160,file = "out3Ghaneh.txt")

do i=-n/2+1,n/2-1
write(160,*)," Integral = ",a_Integral(i)
enddo
pause
!/////////////////////////////////////////////////////////////
contains
!++++++++++++++++++++++++++++++++++++++++++++++++++++++
!function : fermi !

real(8) function fermi(e,mo)
implicit none
real(8),intent(in) :: mo
complex(8),intent(in) :: e(-n/2:n/2)

if(dreal(e(i)) < mo)then
fermi = 1.
else
fermi = 0.
end if

end function fermi

!////////////////// Simpson Integrals Subroutine /////////////////////////////////////
Subroutine Simpson(n,a,b)
Integer,intent(IN) :: n
Real(8),intent(IN) :: a,b
Real(8) :: delta_e,m !n must be an even number
REAL(8) :: wn(-n/2:n/2),e(-n/2:n/2)
complex(8) :: F(-n/2:n/2,-n/2:n/2,-n/2:n/2,-n/2:n/2)
complex(8) :: a_integral(-n/2:n/2),b_Integral(-n/2:n/2,-n/2:n/2),c_Integral(-n/2:n/2,-n/2:n/2,-n/2:n/2)
real(8), external :: fermi
delta_e = ( b - a )/n

!
! Here you introduce your integrant :
!
NN=fermi(e(i1),mo)*fermi(-e(i2),mo)*fermi(e(i3),mo)+fermi(-e(i1),mo)*fermi(e(i2),mo)*fermi(-e(i3),mo)

do i=-n/2,n/2
wn(i) = (2*i + 1)*Pi*Temp
e(i) = wn(i)
F(i,i1,i2,i3)=NN/(ii*wn(i)-e(i1)+e(i2)-e(i3)) !F(i)=NN/(ii*wn(i)-e(i1)+e(i2)-e(i3))

end do

c_integral(i,i2,i3)=F(i,-n/2,i2,i3)+F(i,n/2,i2,i3)

Do i1=(-n/2)+1,(n/2)-1
m=mod(i1,2)
c_integral(i,i2,i3)=c_integral(i,i2,i3)+2*(1-m)*F(i,i1,i2,i3)+4*m*F(i,i1,i2,i3)

END DO
c_integral(i,i2,i3)=c_integral(i,i2,i3)*delta_e/3
!*********************************************************second fold of Integral************************************
b_integral(i,i3)=c_integral(i,-n/2,i3)+c_integral(i,n/2,i3)

Do i2=(-n/2)+1,(n/2)-1
m=mod(i1,2)
b_integral(i,i3)=b_integral(i,i3)+2*(1-m)*c_integral(i,i2,i3)+4*m*c_integral(i,i2,i3)
END DO
b_integral(i,i3)=b_integral(i,i3)*delta_e/3
!*********************************************************third fold of Integral*************************************
b_integral(i,i3)=c_integral(i,-n/2,i3)+c_integral(i,n/2,i3)
Do i2=(-n/2)+1,(n/2)-1
m=mod(i1,2)
a_integral(i)=a_integral(i)+2*(1-m)*b_integral(i,i3)+4*m*b_integral(i,i3)
END DO
a_integral(i)=a_integral(i)*delta_e/3
!********************************************************************************************************************
END Subroutine Simpson
!/////////////////////////////////////////////////////////////
END program INTEG_3Ghaneh
 
Technology news on Phys.org
Is the code you showed in separate files? You are getting linker errors, which means that the linker cannot find the code associated with the symbols _FERMI and _A_INTEGRAL.

It's possible that your configuration file doesn't include all of your source files. Otherwise, I don't see anything obvious.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K