• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 579
  • Last Modified:

What does this unresolved external symbol mean?

I get an error LNK2019: unresolved external symbol.  

1 unresolved externals.

What does this mean?
0
shaolinfunk
Asked:
shaolinfunk
  • 5
  • 3
1 Solution
 
phoffricCommented:
If you declare a function, for example, and you main uses this function, but you forget to define the body of the function, then the linker cannot find the function. The function symbol is unresolved by the linker in that the linker cannot build the executable.
0
 
shaolinfunkAuthor Commented:
ok, so the function must be declared in the header file and defined before/above the main int() function?
0
 
phoffricCommented:
You could also get the same error for variables.
lost_variable is declared, but if it is not defined, i.e.,
    int lost_variable;
somewhere, then it too will be an unresolved symbol.

Notice that if you can compile the code below with no problems. But you will still get an unresolved external symbol.
#include <iostream>
using namespace std;

extern int lost_variable;

int main() {
  cout << lost_variable << endl;
}

Open in new window

0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
evilrixSenior Software Engineer (Avast)Commented:
>>  but you forget to define the body of the function
Or just forgot to link in the object file :)
0
 
phoffricCommented:
I use "declare" as in:
   int foobar( int arg1, float arg2);
The declaration describes the function profile.

I use "define" as in:
   int foobar( int arg1, float arg2) {
      return arg1 + arg2;
   }

The definition can be in a different file that is included in the project. In that case you need the declaration either in the .cpp file where it is used, or in a header file that is included when the foobar function is used.
0
 
shaolinfunkAuthor Commented:
thanks phoffric!!
0
 
phoffricCommented:
Your welcome! Let me know when you get your program completely developed. I'd love to see how to analyze or automate the trades.
0
 
shaolinfunkAuthor Commented:
Will do Phoffric.  If you have any questions about automated trading I can probably help you as well.
0
 
phoffricCommented:
Cool! Can you recommend a book on trading? (p.s. - I'm familiar with covered call/put options.)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now