Lucian
Lucian

Reputation: 354

Visual Studio C++ Solution compilation

My Visual Studio Solution contains the following projects :

Solution
 -> FolderName
      C++ Project Name 1 
      C++ Project Name 2
 -> C++ Project Name 3 
 -> C# Project Name 

C++ Project Name 3 is a library type project (generates a dll and a lib)

C++ Project Name 1 and 2 use a header from C++ Project Name 3 and in the linker section they expect for the lib generated by C++ Project Name 3

If compiled one by one in the project order (3,1,2) everything is compiled correctly and works, but in case i try to compile the entire solution i get a linker error stating that it cannot compile C++ project Name 1 because it cannot find the lib from C++ Project Name 3 .

My question is how can i compile correctly (in the expected order) if i select compile solution ? Next step i have to do is to compile using the build system from TFS and i expect there i will have the same problem

Upvotes: 2

Views: 72

Answers (3)

crashmstr
crashmstr

Reputation: 28583

In Visual Studio, go to the Project menu, then Project Dependencies. Select the project that "needs" the library, and check the library's check box. This will tell Visual Studio how to determine order or compilation.

Note: you can also manually change build order, but by setting dependencies, Visual Studio can work out the order itself, which may be more optimal.

MSDN: How to: Create and Remove Project Dependencies

Upvotes: 4

Fletchius
Fletchius

Reputation: 460

Use the Project Dependencies, Common Properties, Solution Property Pages Dialog Box to set the current build order. To access this dialog box, select a solution in Solution Explorer, choose Property Pages on the View menu, and then select Project Dependencies under Common Properties.

https://msdn.microsoft.com/en-us/library/zk4ahe0t(v=vs.90).aspx

Upvotes: 0

RyanL
RyanL

Reputation: 468

It sounds like you need to set up your project dependencies for the solution. How to: Create and Remove Project Dependencies

Upvotes: 1

Related Questions