简体   繁体   English

同一解决方案中不同项目之间的引用(Visual Studio 2012)

[英]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.

相关问题 在多项目Visual Studio解决方案中以不同配置编译项目 - Compiling projects in different configurations in a multi-projects Visual Studio Solution 具有相同名称功能的具有不同项目的Visual Studio解决方案 - Visual Studio solution with different projects with functions of the identical name IncrediBuild 在一个线程中编译 Visual Studio 2010/2012 解决方案的一些项目 - IncrediBuild compile some projects of Visual Studio 2010/2012 solution in one thread Visual Studio 2012调试多个项目 - Visual Studio 2012 Debugging multiple Projects Visual Studio 2012:没有可变参数模板:解决方案? - Visual Studio 2012 : no variadic templates : a solution? Visual Studio解决方案:静态或共享项目? - Visual Studio Solution: static or shared projects? 在Visual Studio解决方案中链接两个项目 - Linking two projects in a Visual studio solution 使用cmake和visual studio在一个解决方案中的几个项目 - Several projects in one solution with cmake and visual studio 具有多个项目的visual studio解决方案无法编译 - visual studio solution with multiple projects doesnt compile 如何在同一解决方案中的项目之间共享变量? - How to share variable between projects in the same solution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM