简体   繁体   中英

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. 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.

It seems like it Works because the intellisence can locate the correct .h files when I include them in the Server project.

在此处输入图片说明

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. They look like on the image.

在此处输入图片说明

Can you help me with that?

BR

Your linker error indicates that your SOCK_Stream class is not tagged with the correct dllimport/dllexport macros.

There are many ways of fixing the issue. This is just a basic way

1) In your SOCK_Stream class header add the macros:

#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

class SOCK_STREAM_DLL SOCK_Stream {
...
};

3) Define the BUILDING_SOCK_STREAM symbol in your WrapperFacade project (Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions)

The goal is to get WrapperFacade to export the symbols that you want to link against from your Server project. By not defining BUILDING_SOCK_STREAM in Server, the macro will default to __declspec(dllimport).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM