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

How to resolve error 2019: Unresolved external symbol _DATA

lad__aishwarya
Beginner
2,303 Views

Hello, I'm trying to compile a simulation code to run on a software using Fortran77. Using a Windows 10 OS using Intel Visual 2019 on Visual Studio 2019

As I open the .sln file provided and add the library and source code file in Visual Studio, after build command I get the following errors,

Severity    Code    Description    Project    File    Line    Suppression State
Error        fatal error LNK1120: 1 unresolved externals        Release\MyType.dll        

Severity    Code    Description    Project    File    Line    Suppression State
Error        error LNK2019: unresolved external symbol _DATA referenced in function _TYPE851        Type851.obj     
I've been through documentation at Microsoft docs and tried the basic stuff yet its the same. Is this because the.sln file that is provided with the software was originally for IVF 10.1? or because there is something I'm missing out or doing wrong? I also tried to include different library files (not the ones provided with the .sln file) the errors seem to be the same and with some files the unresolved externals seem to increase but the nature of errors remain the same.

This is my first time coding and I'm clueless.

P.S. I've attached .sln file

0 Kudos
1 Solution
Arjen_Markus
Honored Contributor I
2,303 Views

The problem is not so much in the solution file, but in your code. As you did not supply that, we cannot give you specific advice. How big is it? You mention several libraries and a "simulation code". That seems to indicate that you are using a system for simulations and that you need to add the code that describes your particular simulation model. It may not possible for you to provide all the stuff so that we can reproduce the problem ;).

Perhaps you should start by looking in your code where you use "data" as a name and see whether the component that defines it is part of the build steps.

View solution in original post

0 Kudos
8 Replies
Arjen_Markus
Honored Contributor I
2,304 Views

The problem is not so much in the solution file, but in your code. As you did not supply that, we cannot give you specific advice. How big is it? You mention several libraries and a "simulation code". That seems to indicate that you are using a system for simulations and that you need to add the code that describes your particular simulation model. It may not possible for you to provide all the stuff so that we can reproduce the problem ;).

Perhaps you should start by looking in your code where you use "data" as a name and see whether the component that defines it is part of the build steps.

0 Kudos
muzammil__muhammad
2,296 Views

Good day sir here is my code in intel FORTRAN 77 for finding the roots

but after compiling it I got two errors

1)unresolved externals

2)unresolved external symbol _MAIN_references in function_main

how to resolve these two fatal errors?

 

 

here is my code

!calculating zeros for a function

 

double precision function zeroin(ax,bx,f,tol)

double precision ax,bx,f,tol

double precision a,b,c,d,e,eps,fa,fb,fc,tol1,xm,p,q,r,s

double precision dabs,dsign

c

c compute eps, the relative machine precision

c

eps = 1.0d0

10 eps = eps/2.0d0

tol1 = 1.0d0 + eps

if (tol1 .gt. 1.0d0) go to 10

c

c initialization

c

a = ax

b = bx

fa = f(a)

fb = f(b)

c

c begin step

c

20 c = a

fc = fa

d = b - a

e = d

30 if (dabs(fc) .ge. dabs(fb)) go to 40

a = b

b = c

c = a

fa = fb

fb = fc

fc = fa

c

c convergence test

c

40 tol1 = 2.0d0*eps*dabs(b) + 0.5d0*tol

xm = .5*(c - b)

if (dabs(xm) .le. tol1) go to 90

if (fb .eq. 0.0d0) go to 90

c

c is bisection necessary

c

if (dabs(e) .lt. tol1) go to 70

if (dabs(fa) .le. dabs(fb)) go to 70

c

c is quadratic interpolation possible

c

if (a .ne. c) go to 50

c

c linear interpolation

c

s = fb/fa

p = 2.0d0*xm*s

q = 1.0d0 - s

go to 60

c

c inverse quadratic interpolation

c

50 q = fa/fc

r = fb/fc

s = fb/fa

p = s*(2.0d0*xm*q*(q - r) - (b - a)*(r - 1.0d0))

q = (q - 1.0d0)*(r - 1.0d0)*(s - 1.0d0)

c

c adjust signs

c

60 if (p .gt. 0.0d0) q = -q

p = dabs(p)

c

c is interpolation acceptable

c

if ((2.0d0*p) .ge. (3.0d0*xm*q - dabs(tol1*q))) go to 70

if (p .ge. dabs(0.5d0*e*q)) go to 70

e = d

d = p/q

go to 80

c

c bisection

c

70 d = xm

e = d

c

c complete step

c

80 a = b

fa = fb

if (dabs(d) .gt. tol1) b = b + d

if (dabs(d) .le. tol1) b = b + dsign(tol1, xm)

fb = f(b)

if ((fb*(fc/dabs(fc))) .gt. 0.0d0) go to 20

go to 30

c

c done

c

90 zeroin = b

return

end

 

real function f(x)

f=x*x-4

return

end

0 Kudos
mecej4
Honored Contributor III
2,282 Views

MODERATOR:

Please move Muzzamil's post to a new thread, if possible. It is unrelated to the original thread.

0 Kudos
mecej4
Honored Contributor III
2,281 Views

Please do not add a new post to an unrelated old thread. Instead, start a new thread and give it an appropriate title.

When you post code, use the code button (symbol: </> in the tool bar above the box where you type your posts).

You have to add a main program that calls your zeroin routine. For example:

      program solve
      double precision, external :: f,zeroin
      
      print *,zeroin(-3d0,1d0,f,1d-4)
      end program

You have type inconsistencies in your code, which you need to fix before being able to run the program correctly.

0 Kudos
FortranFan
Honored Contributor II
2,303 Views

@lad, aishwarya:

As mentioned in post #2, it's the Fortran source code that will be the starting point to give you some guidance toward resolving your problem.

Do you have a file and/or a Fortran subprogram named 'TYPE851' in your code?  If yes, can you share that code in this thread?  If yes, it'll be best if you use the button with {..} with a subscript labeled "code" under "Leave a Comment" field when you post your reply.

Note the term 'DATA' is too generic and it can imply any number of things including the name of a statement in Fortran language.  But then Fortran does not have reserved keywords and your code can be trying to reference a function named DATA too that the linker is unable to find or when what is intended is an array named DATA; or it can be some other issue entirely.   

0 Kudos
lad__aishwarya
Beginner
2,303 Views

@Arjen Markus @FortranFan

As you mentioned I went through the code again and there was a call for data if some of the calculated values needed to be called via an external file. As I didn't need to use that option, I deleted all the related syntax and tried to build again, the error was gone. Perhaps a new error occured which was as below

Severity    Code    Description    Project    File    Line    Suppression State
Error        error PRJ0019: A tool returned an error code from "Copying Release MyType.dll to the UserLib folder"        Project  

As I checked UserLib folder, there was an existing .pdb file generated during one of previous run. After deleting the .pdb file I tried to rebuild the project but was getting the same error. If I'm not wrong there is an error in copying the file which is generated after the build is complete, is it okay if I manually copy the file to userlib folder?

0 Kudos
FortranFan
Honored Contributor II
2,303 Views

lad, aishwarya wrote:

@Arjen Markus @FortranFan

As you mentioned I went through the code again and there was a call for data if some of the calculated values needed to be called via an external file. As I didn't need to use that option, I deleted all the related syntax and tried to build again, the error was gone. Perhaps a new error occured which was as below

Severity    Code    Description    Project    File    Line    Suppression State
Error        error PRJ0019: A tool returned an error code from "Copying Release MyType.dll to the UserLib folder"        Project  

As I checked UserLib folder, there was an existing .pdb file generated during one of previous run. After deleting the .pdb file I tried to rebuild the project but was getting the same error. If I'm not wrong there is an error in copying the file which is generated after the build is complete, is it okay if I manually copy the file to userlib folder?

It's possible your Visual Studio project has a post-build event (https://docs.microsoft.com/en-us/cpp/build/specifying-build-events?view=vs-2019) that attempts a file copy: you can take a look there and check what's needed.

Re: manual copy, please note first it's not a Fortran issue.  You may want to check if this "simulation code" has some developer/support staff/documentation you can tap into, or if there are other users who can offer any advice.  Note the usual good/correct practices on Windows 10 OS should apply. 

0 Kudos
lad__aishwarya
Beginner
2,303 Views

I went through the build log file and realised there was one folder missing in he path. After adding the folder in the path, could successfully build both release and debug dlls. Thank you guys

 

0 Kudos
Reply