Reputation: 4246
I have a VC++ solution with two projects. Project B references project A. Project B also has as Include Directory (Properties/Configuration Properties/C++/Additional Include Directories) the folder from Project A. No namespaces are used.
When i Import the header from a Project A class like #include "someFolder\SomeClass.h"
then I'm able to declare a pointer to the class.
SomeClass *sc;
But as soon as i call the constructor it won't compile. IntelliSense doesn't show any errors.
SomeClass *sc = new SomeClass("someString");
I get:
error LNK2001: "unresolved external symbol "public_ thiscall SomeClass::SomeClass(..." and "error LNK1120: 1 unresolved externals".
The constructor is public just like the methods from SomeClass. The funny thing is that I can compile when calling methods from SomeClass in Project B. Only the cunstructor does not seem to work.
Upvotes: 2
Views: 1995
Reputation: 28728
You have to link the object code compiled from "SomeClass.cpp". If Project A compiles to a static library, then add a reference to it.
Upvotes: 2
Reputation: 122001
The source does compile, this is a linker error. You need to add the library (.lib) files from Project A to the linker command in Project B.
Upvotes: 1