I have a header file, let's call it header1.h
with the definition of a function, let's say myFunc()
in it. My C++ project has a source file, let's call it main.cpp
and a header file main.h
. I have included header1.h
in the main.h
and then included main.h
in main.cpp
.
In the main.cpp
I have a class constructor let's call it MyClass
and I have this code:
MyClass:MyClass(...)
.
.
{
.
.
f = myFunc(...);
.
}
when I compile the code I get this error:
error LNK2019: unresolved external symbol _myFunc referenced in function
What is the reason for this error?
That is a linker error. The file which contains the definition of myFunc
is not being compiled, or you are not linking to the library which exported it.