2014-10-17 45 views
0

它的.cpp超出这个应该是简单的,但我失去的睡眠了它:(VS2010如何.H连接到项目的目录

我有几个班分成的.h和.cpp,我在项目之外放置到一个单独的'classes'文件夹中,以便多个项目可以访问它们。

在项目属性 - > VC++目录下 我改变了'include directories'参数,

从我的类的.h似乎可以在项目中使用,但我的.cpp没有被链接正确,因为它们导致“编译时出现错误LNK2019:无法解析的外部符号”问题。我找不到类似的论坛主题的解决方案有关链接的问题...

//this is how the .cpp starts 
//is the path wrong ? Am I missing a VS2010 setting somewhere ? 
//I've tried several alternatives including full path name, brackets.. 
#include "CMyClass.h" 

我的目录看起来像“Visual Studio 2010的.. \ \项目\”

project_one //wants to use a class from the 'classes' folder 
project_two //also wants to use a class from the 'classes' folder 
classes //.h and .cpp are in here 

的类都被这下在自己的游戏机中进行测试,所以定义肯定存在。这些类位于与项目分离的新目录中。

如何让他们找到他们的.cpp?

回答

2

对于每个项目,右键单击它并选择“添加现有项目...”并选择您的共享CPP文件。每个CPP文件都必须添加到每个使用它的项目中。这不会复制磁盘上的CPP文件,并且它们是否位于磁盘上的项目目录之外并不重要。

+0

谢谢!这完美地回答了它 – Soran 2014-10-17 02:46:52