Fatal error LNK1120: 2 unresolved externals

  • Thread starter Thread starter nnnnn
  • Start date Start date
  • Tags Tags
    Error
Click For Summary
SUMMARY

The forum discussion addresses a linking error encountered in a Fortran 90 program using Compaq Visual Fortran 6.0. The specific errors reported are LNK2001 for unresolved external symbols _FERMI@8 and _A_INTEGRAL@4, indicating that the linker cannot find the definitions for these functions and variables. The user is advised to ensure that all relevant source files are included in the project configuration to resolve these linker errors.

PREREQUISITES
  • Understanding of Fortran 90 programming language
  • Familiarity with Compaq Visual Fortran 6.0 IDE
  • Knowledge of linking processes in programming
  • Experience with debugging linker errors
NEXT STEPS
  • Review project settings in Compaq Visual Fortran to ensure all source files are included
  • Learn about Fortran external functions and how to properly declare them
  • Investigate common linker errors and their resolutions in Fortran
  • Explore best practices for organizing Fortran code across multiple files
USEFUL FOR

This discussion is beneficial for Fortran developers, particularly those using Compaq Visual Fortran, who are troubleshooting linker errors and seeking to improve their understanding of project configuration and external function declarations.

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.
 

Similar threads

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