I don't understand why the linker says it can't find this function when I add something to my class.
// In .h file
class Importer
{public:
void importOBJFile();
}
// In .cpp file
// INCLUDE ALL THE ASSIMP LIBRARY HEADERS HERE
void Importer::importOBJFile()
{
Assimp::Importer importerInst;
const aiScene* scene = importerInst.ReadFile("filename", aiProcess_Triangulate);
}
Everything works fine like this. However if I add:
const class aiScene* scene = nullptr;
... to my class definition, or forward declare class aiScene; and then just add:
const aiScene* scene = nullptr;
... to my class definition, then I get an error compiling:
Error LNK2019 unresolved external symbol "public: class aiScene const
- __cdecl Assimp::Importer::ReadFile(char const *,unsigned int)" (?ReadFile@Importer@Assimp@@QEAAPEBVaiScene@@PEBDI@Z) referenced in function "public: class aiScene const * __cdecl Assimp::Importer::ReadFile(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,unsigned int)" (?ReadFile@Importer@Assimp@@QEAAPEBVaiScene@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I@Z)
Why is it complaining that it can't find the readFile function when I just forward declare aiScene class and add a pointer declaration to the class definition?
Pasting all the Assimp library headers in the .h file before my Importer class fixes this, but I wanted to avoid pasting headers in headers, and I can't understand why this is happening.
I am on Visual Studio 2019