Visual Studio copies and copies C++ project and third-party library configuration information to a new project

  This article introduces how to copy an existing C++ project configured with various third-party libraries in Visual Studio software and copy it into a new project . At the same time, the new project can directly use the various types of configurations in the original project. **C++** methods for configuration, third-party libraries , etc.

  When writing C++ code, if you need to use a third-party library written by others , you need to reconfigure the environment every time you create a new project , which is relatively troublesome; and if we configure different third-party libraries in one project first library, and create a new project under the same device and environment , and the new project also hopes to use the same third-party library, then we do not need to reconfigure these libraries, but can directly use the previous project Just configure the file in . This operation is described in our previous two articles: the method of Visual Studio software calling the configured and compiled C++ third-party library (https://blog.csdn.net/zhebushibiaoshifu/article/details/127171298), and the method of Visual Studio Methods for quickly configuring C++ third-party libraries compiled in existing projects for new projects have been introduced in (https://blog.csdn.net/zhebushibiaoshifu/article/details/128292242); and this time, we introduce a A more convenient method is to copy and paste the project files directly in the resource manager . Of course, this method requires that the new project we copy and create and the old project be in the same environment on the same computer to be effective.

  First, we have a project folder named Project folder under a folder LCCProduction_4. This is the project we want to copy. The project name is this LCCProduction_4; as shown in the figure below.

  Open the project folder as shown below.

  So in order to copy this project, first, we need to copy the project folder and rename the newly obtained folder (just rename it with the name of our new project ); I will rename it here LCCProduction_5; as shown below shown.

  Next, we enter the renamed new project folder and first delete the two folders in the purple box above in the picture below. Of these two folders, the first one .vsrecords some of our configurations in the solution, such as recently opened windows, window layouts, breakpoint settings, etc.; the second folder x64records the results after the project is compiled; These folders will be automatically updated after we copy, copy and run the new project, so just delete them now.

  Secondly, for the files in the second purple box in the picture above, part of the original file name is the name of the old project , that is LCCProduction_4(I have modified it when I took the screenshot here); we all change the name of the old project Just change this part to the new project name (here it is LCCProduction_5). It should be noted here that the number and specific file formats of these files in your project folder may not be exactly the same as the ones in the picture here. You can just modify the files with old names to new names according to the actual situation .

  Then, as shown in the picture above, we open the file at the end, which can be opened with any text editor; then, find the " Replace.vcxproj " function in the editor .

  Next, in the replacement, set the original content to our original project name , and set the new content to our new project name ; as shown in the figure below. But something to note here is that I found .vcxprojthat in the file at the end, the underscore in my original project name no longer existed, so when I replaced it with a new project name, I also removed the underscore in the new project name. When you actually operate, you can modify it based on the actual situation in your own file.

  Subsequently, we open the Visual Studio software and select the " Open Project or Solution " option, as shown in the figure below.

Then, find the new project folder   we just modified and select .vcxprojthe file at the end of it, as shown in the figure below.

  It should be noted here that if you choose another .slnfile to open the project (as shown in the figure below), an error will be reported at runtime.

  After opening the new project, we can see that the code files from our previous project are already in the " Header Files " and " Source Files ".

  At this point, you can run the new project. Of course, if there are words about the old project name in your code file, it may need to be replaced and modified before it can run normally. Because the name of the old project is not involved in the code here, it can run normally. In this way, the old project and the new project can still run at the same time, which is a bit like manually setting up a multi-thread.

  At this point, you're done.

Welcome to follow: Crazy Learning GIS

Guess you like

Origin blog.csdn.net/zhebushibiaoshifu/article/details/132940838