Fatal error LNK1120: 2 unresolved externals

  • Thread starter nnnnn
  • Start date
  • Tags
    Error
In summary: Have you tried writing a simpler program that calls the _FERMI and _A_INTEGRAL functions in a simpler context?In summary, the conversation is about a programming problem involving unresolved external symbols _FERMI and _A_INTEGRAL. The code provided is for a Fortran program that uses the Simpson Integrals subroutine and Fermi function. The error message suggests that the linker cannot find the code associated with these symbols. Possible solutions discussed include checking the configuration file and writing a simpler program to test the functions.
  • #1
nnnnn
5
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
  • #2
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.
 
  • #3


Hello N.M.,

Thank you for reaching out for help with your program. The error you are receiving, "fatal error LNK1120: 2 unresolved externals," means that the linker was unable to find the definitions for two external symbols, specifically "_FERMI@8" and "_A_INTEGRAL@4." This means that these symbols are being used in your program, but the linker is unable to find where they are defined.

There are a few potential causes for this error. One possibility is that you have not properly declared or defined these symbols in your program. Make sure that you have declared them as external functions or variables before using them. Another possibility is that you are missing a library or module that contains the definitions for these symbols. Make sure that you have included all necessary libraries and modules in your program.

I also noticed that your program contains a subroutine called "Simpson" which is being called in your main program. However, I do not see a definition for this subroutine in your code. Make sure that you have defined this subroutine before calling it in your main program.

I hope this helps to resolve your issue. If you continue to have trouble, I suggest seeking help from a more experienced Fortran programmer or consulting the documentation for your compiler. Good luck with your program!
 

1. What does the "Fatal error LNK1120: 2 unresolved externals" mean?

The "Fatal error LNK1120: 2 unresolved externals" is an error message that appears when the linker is unable to find the definition of two external symbols in the program. This means that the linker is unable to link the object or library files to create the final executable.

2. What can cause this error to occur?

This error can occur due to a variety of reasons, such as missing or incorrect function declarations, incorrect use of libraries or header files, or missing object or library files. It can also occur if the linking order of the files is incorrect.

3. How can I fix this error?

To fix this error, you will need to identify the missing or incorrect external symbols and ensure that they are properly declared and defined in the code. You may also need to check the linking order of the files and make sure that all necessary object and library files are included in the project.

4. Can this error be prevented?

This error can be prevented by ensuring that all external symbols are properly declared and defined, using the correct libraries and header files, and maintaining the correct linking order of files. It is also important to regularly test and debug the code to catch any potential errors before they occur.

5. Are there any resources available to help troubleshoot this error?

Yes, there are many online resources and forums where you can find helpful tips and solutions for troubleshooting this error. You can also refer to the documentation of your programming language or development environment for specific guidelines on resolving linker errors.

Similar threads

  • Introductory Physics Homework Help
Replies
9
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
Replies
7
Views
1K
  • Programming and Computer Science
Replies
4
Views
588
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
20
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Nuclear Engineering
Replies
7
Views
2K
Back
Top