I’ve got a problem with my code. It basically looks like this:
someclass.hpp:
class SomeClass
{
public:
SomeClass();
~SomeClass();
//... some other methods
};
someclass.cpp:
#include "SomeClass.hpp"
SomeClass::SomeClass()
{
}
SomeClass::~SomeClass()
{
}
SomeClass.cpp doesn’t include anything else.
The constructors are actually empty, too. I just don’t want to leave them undefined or leave the standard constructor because I’m probably going to need it later.
SomeClass.hpp is actually a gamestate class which is included in only one place:
main.cpp
#include "SomeClass.hpp"
int main()
{
DoSomethingWithGamestate(new SomeClass());
return 0;
}
And then the project consists of a lot of other files, all of which are independent from SomeClass, though.
The problem is that whenever I change anything in the code, no matter in which file, I have to recompile the entire solution because if I only compile the changes the linker throws this:
error LNK2001: unresolved external symbol "public: __thiscall SomeClass::SomeClass(void) (??blablaSomeClassblabla)
Obviously, there’s something weird going on here, since SomeClass() is clearly defined in someclass.cpp.
What could be the source of this?
In addition to what @Nawaz says, it’s likely your build files are out of sync with the linker so that when Visual Studio goes to re-link, it can’t because the files are out of sync. Just re-build and be done with it.
By the way, it may even be a bug in Visual Studio 2010 as seen here.