
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are undefined reference/unresolved external symbol errors in C++?
As the name suggests, a symbol you declared was not defined by you. This may occur due to many cases. Let's have a look at three of them −
You forgot to define the declared name. For example, you declared a function in a file and used it somewhere. But you did not provide its definition. Code −
#include<iostream> void foo(); int main() { foo(); // Declared but not defined }
You defined it but did not use the qualified name. Say you created a class with a method and defined that method but forgot using scope resolution to link that function to that definition and used that function somewhere. For example,
#include<iostream> class A { void foo(); }; void foo() { } // should have used A::foo int main() { A a; a.foo(); // Not defined! }
You did not include dependencies in incorrect order. The linker tries to link in the order you specify to it. So in case you use a method before its definition, it will likely give this error.
Creating an exhaustive list of conditions that can cause this error is not possible. But you can refer to this post for a very well-curated list of likely reasons − https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix
- Related Questions & Answers
- What are reference data types in C#?
- What are syntax errors in JavaScript?
- What are runtime errors in JavaScript?
- What are Memory Reference Instructions?
- Errors in C/C++
- What are reference data types in Java?
- What are the different types of errors in JavaScript?
- Are Python Exceptions runtime errors?
- Undefined Behaviour in C and C++
- What are the data types, value types and reference types in C#?
- What are common programming errors or 'gotchas' in Python?
- How are errors classified in trial balance?
- What is the Symbol Table?
- What is a reference variable in C++?
- What are all the common undefined behaviours that a C++ programmer should know about?