Search code examples
c++visual-c++linkerinclude

Linker not recognizing some #includes?


I have a VC++ solution with multiple projects and multiple namespaces. Each project has its own namespace, and some projects have multiple namespaces.

Sometimes, when I reference an object from another project I will end up with "unresolved external symbol" errors even though I #included the header file and referenced the object through it's namespace (Namespace::object). In order to get rid of the linker errors I have to also #include the cpp file, then I get warnings that the symbol was defined twice.

This is very hackish and I don't like hackish.

I know that I need to go through and look at all the include dependencies, since something's obviously screwed up, but I haven't been able to find any major problems as of yet.

In the mean time, does anyone have any suggestions for anything obvious to check or any common causes to this problem?


Solution

  • If you are using Visual C++, Go to your project properties, under Linker > Input, you should add the compiled .lib file of the project you are depending on.
    Like others have stated, the compilation unit you are missing has nothing to do with files you #include (which are only relevant for compilation, not linkage)