7heViking
7heViking

Reputation: 7577

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:

enter image description here

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.

enter image description here

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.

enter image description here

Can you help me with that?

BR

Upvotes: 0

Views: 712

Answers (1)

Ben
Ben

Reputation: 1367

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

Upvotes: 1

Related Questions