I'll take you to the visual studio--to bring you multiple engineering development

Source: Internet
Author: User
Tags win32

The previous article takes you to play the visual studio--to take you to manage a variety of published books let us know the difference between debug and release and learn how to manage multiple versions of different releases. In a large project, there are often more than one project, and there will be multiple projects interconnected, and each project will have its own published edition, which is what this article will tell. a solution multiple project Introduction to multiple Projects

I'm going to show you how to do it. Visual studio--take you to a new project the article mentions that a solution (solution) can have more than one project (project), when there is a need for more engineering. What are the benefits of multiple projects?

Scenario: When a project consists of a number of different components (modules), create a project for each component, and all components work under the same solution.
Advantages: The structure is clear, can be divided into module development, the complex program to decouple. Create a multiple project

Let's take the Utils project for example, in the article with you to release your own engineering library and the previous article with you management of a variety of release version has created a Utils project, and compiled a number of versions of the library, but we use this library is under another solution, In fact, we can and should also put the use of Utils Library engineering and Utils project under a solution.

New Project is added to the existing solution , file->new->project ... Open New Project dialog box to create a new Usingutils project, notice that in the Solution column we choose Add to solution.

Add a Project

Add a reference association , then we need to use this utils compiled library, the preparation is also simpler. Right-click Usingutils Engineering->properties->common properties->framework and references to add a reference (dependent) project Utils. After you set up a reference association, if the Utils project changes or updates, the Utils project will be recompiled when the Usingutils project is compiled.

Add a reference association

sets the path of the header file .

To set the path of a header file

To set up the startup Project , you have to set up the startup project in the solution with multiple projects (that is, the first project to start execution), or you don't know which project to start when you press F5. Select Usingutils Project name right mouse->set as Startup project. You can then perform or debug the Usingutils project. compilation results and directory management

When multiple components are developed at the same time, it is much easier to put related project under the same solution. But have you ever found a new problem if a solution has a lot of project, each project directory will have a compilation result directory, as shown below you faint.

Compiling results Directory

How do you manage these directories so that they don't look so cluttered? In fact, we can set the output path of these directories, you can put them together to manage. We can design the output directory like this: Utils
Utils usingutils Output
Win32
Debug
Bin Lib Temp Release
Bin Lib Temp Linux
Debug
Bin Lib Temp Release
Bin Lib Temp

It looks like it's a much clearer structure. Output directory, Win32 for the Windows X32 compiled structure, Linux for the Linux platform compiler results (this involves cross-platform development, not talk about), Win32 under the Debug and release and so on a number of different published publications, Bin to place the final compiled results (such as. exe, etc.), put all the compiled. lib files under Lib, temp place temporary files for the compilation process (such as. obj, etc.).

We still take utils as an example to explain. The Utils solution has two project:utils (compiled out of the Utils ToolPak) and Usingutils (using Utils libraries), only to be explained by the release of Debug_static, and other ways of releasing it are similar.

all project uses the same set of compounding items.
What does that mean. We're taking you for a spin. Visual studio--to take you to manage multiple-release publishing this article said that debug and releases are a set of configuration items, in fact, the entire solution has a configuration, each project also has its own configuration items.
The entire solution configuration is what you can see in the following Diagram toolbar:

Compounding items of Solution
And each project's preparation is your right key project name->properties can see the configuration items:

Project's Compounding item
In general, all project under a solution is best to use the same set of items, so it is not easy to confuse.

Add debug_static compounding items to usingutils. when we set the properties of the utils, we have already formulated the Debug_static configuration item, set up the solution debug_static compounding item, and then add Usingutils's compounding item to the debug_static.

Add a compounding item
The Create new solution configurations for the label "4" indicates that the entire solution also adds (debug_static) The compounding item, this check box should be canceled. Because the Debug_static configuration item has been added to solution by default when the Utils is set, it will not be added.

set utils output path , right key Utils engineering->properties for the following preparation.

Set Output path

Copy the Export library. Lib, we can copy the Utils compiled static library Utils.lib to the Lib directory, so that we can directly provide this file to the caller to use.


The build events can set up processing events before, before, and after the compilation. Here we are compiling the compiled Utils.lib copy to the Lib folder, so we enter the following command at Post-build event

: If the Lib directory does not exist, the side creates this directory if not
exist $ (solutiondir) output\win32\$ (Configuration) \lib MD $ (SolutionDir) output\win32\ $ (Configuration) \lib
: Copy (ProjectName). lib file to Lib directory
copy/y $ (solutiondir) output\win32\$ (Configuration) \ bin\$ (ProjectName). Lib $ (solutiondir) output\win32\$ (Configuration) \lib\

set the output path for the Usingutils , similar to the utils as follows:

Set the output path of the Usingutils

set to complete , Ok, compile and then look at the output directory, is not much clearer.

New Output Results Directory

Previous review:
I'll take you to the visual studio--. Manage multiple Release publications

What to tell in the next article:
Take you to the visual studio--take you to understand Microsoft's precompiled header Technology

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.