[英]Reference between different projects in the same solution (Visual Studio 2012)
I can't get this reference to work. 我无法获得此参考资料。 I have 2 project in my solution. 我的解决方案中有2个项目。 A wrapper facade and a server: 包装外观和服务器:
I have added the path to "wrapper facade" in the additional include directories in: Server property pages -> Configuration properties -> C/C++ -> General. 我在其他包含目录中的“包装外观”路径中添加了路径:服务器属性页->配置属性-> C / C ++->常规。
It seems like it Works because the intellisence can locate the correct .h files when I include them in the Server project. 似乎可行,因为当我将它们包含在Server项目中时,智能可以找到正确的.h文件。
The problem is that I get some LINK problems that I can't solve when I try to initiate a class from the Wrapper facade. 问题是,当我尝试从Wrapper外观初始化类时,遇到了一些无法解决的LINK问题。 They look like on the image. 它们看起来像图像上的。
Can you help me with that? 你能帮我吗?
BR BR
Your linker error indicates that your SOCK_Stream class is not tagged with the correct dllimport/dllexport macros. 您的链接器错误表明您的SOCK_Stream类未使用正确的dllimport / dllexport宏标记。
There are many ways of fixing the issue. 有许多解决此问题的方法。 This is just a basic way 这只是一个基本方法
1) In your SOCK_Stream class header add the macros: 1)在您的SOCK_Stream类标题中添加宏:
#ifdef BUILDING_SOCK_STREAM
#define SOCK_STREAM_DLL __declspec(dllexport)
#else
#define SOCK_STREAM_DLL __declspec(dllimport)
#endif
2) Tag your SOCK_Stream class with the SOCK_STREAM_DLL macro 2)用SOCK_STREAM_DLL宏标记您的SOCK_Stream类
class SOCK_STREAM_DLL SOCK_Stream {
...
};
3) Define the BUILDING_SOCK_STREAM symbol in your WrapperFacade project (Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions) 3)在WrapperFacade项目中定义BUILDING_SOCK_STREAM符号(配置属性-> C / C ++->预处理程序->预处理程序定义)
The goal is to get WrapperFacade to export the symbols that you want to link against from your Server project. 目的是使WrapperFacade从Server项目中导出要链接的符号。 By not defining BUILDING_SOCK_STREAM in Server, the macro will default to __declspec(dllimport). 通过不在服务器中定义BUILDING_SOCK_STREAM,宏将默认为__declspec(dllimport)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.