In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use CMake 3.18.3 to compile and install yaml-cpp library in VS2019". In daily operation, I believe that many people have doubts about how to use CMake 3.18.3 to compile and install yaml-cpp library in VS2019. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the question of "how to use CMake 3.18.3 to compile and install the yaml-cpp library in VS2019"! Next, please follow the editor to study!
1. Application background
As a result of using C++ to write the console program in the process of using more yaml files, the current use of more is the yaml-cpp C++ yaml parsing library. I have written two previous articles about compiling the yaml- CPP library under CentOS7 and using VS2017 and using the yaml-cpp library under Windows10.
Recently, the actual project has been replaced by the latest version of Visual Studio 2019, and the Windows systems I use are Win7 and Windows10, so I need to recompile the static lib library based on the Debug of yaml-cpp under VS2019 and the Release version of Win32. The general steps are consistent with the blog description of using VS2017 to compile and use yaml-cpp library under Windows10.
2. Download the yaml-cpp source code
First download the source code from https://github.com/jbeder/yaml-cpp
Git clone https://github.com/jbeder/yaml-cpp.git
Use git pull substitution code
Or download the zip file directly on https://github.com/jbeder/yaml-cpp and extract it to the specified file directory:
3. Use VS2019 and CMake3.18.3 to compile yaml-cpp
First make sure that VS2019 and CMake are installed on your own system
My system is Windows7, VS2019, CMake 3.18.3. You can choose Windows10 or CMake 3.19.2 according to your needs.
The directory structure of the decompressed yaml-cpp source code package is as follows:
It is easy to introduce CMake compilation using yaml-cpp under Windows10 on the Github repository, as shown in the following figure:
Download the yaml-cpp source code and extract it to the F:\ rate\ iot_sdk\ third_part directory, and then create a build directory under this directory to store the intermediate files during the compilation process. This is mainly in order not to affect the source code. If you make a mistake, you can delete it and start over.
My command to compile yaml-cpp with VS2019 and CMake 3.18.3 on Windows7 is as follows:
Cmake.. -G "Visual Studio 16 2019"-A Win32-DCMAKE_INSTALL_PREFIX=F:\ rate\ iot_sdk\ third_part\ yaml-cpp\ install-DYAML_BUILD_SHARED_LIBS=OFF..
Or
Cmake.. -G "Visual Studio 16 2019 Win32"-DCMAKE_INSTALL_PREFIX=F:\ rate\ iot_sdk\ third_part\ yaml-cpp\ install-DYAML_BUILD_SHARED_LIBS=OFF..
The above-G command specifies VS2019 as the tool, and-DCMAKE_INSTALL_PREFIX specifies the installation directory
-DYAML_BUILD_SHARED_LIBS specifies whether to compile the dynamic library switch, ON means to compile the dynamic library, and OFF means that the dynamic library is not compiled and only the static library is compiled.
Then use VS2019 to open the YAML_CPP.sln project file, as shown in the following figure:
3.1.Using VS2019 to compile the yaml-cppd.lib library of Win32 Debug schema
Select the platforms and schemas that need to be compiled, such as Win32/Win64 and Debug/Release
Select Debug and Win32 above, and then right-click "solution"-"[generate solution]
Then some static libraries of Debug based on Win32 platform will be generated.
This yaml-cppd.lib is the Debug static library based on the Win32 platform compiled by us using the VS2019 project. We need to introduce this lib library in the project of developing yaml-cpp with VS2019.
3.2.Use VS2019 to compile the yaml-cpp.lib library for Win32 Release mode
Select Release, Win32, and right-click * * solution * *-> * * generate solution * *, as shown below:
The method of using VS2019 to compile Win64-bit Debug libraries and Release libraries under Windows7 is similar, with the corresponding CMake compilation command:
Cmake.. -G "Visual Studio 16 2019 Win64"-DCMAKE_INSTALL_PREFIX=F:\ rate\ iot_sdk\ third_part\ yaml-cpp\ install-DYAML_BUILD_SHARED_LIBS=OFF..
After the YAML-CPP.sln project project is generated, open it using VS2019, select the Win64-bit Debug or Win64 Release mode respectively, and then right-click "solution"-"generate solution" to generate yaml-cppd.lib and yaml-cpp.lib files in the corresponding directory, respectively.
4. Use yaml-cpp library to read and write yaml files in VS2019
This introduces the yaml-cpp library in VS2019 in the same way as in VS2017. For more information, please refer to my previous blog, Windows10, using VS2017 to compile and use the yaml-cpp library.
The config.yaml file for the test is as follows:
LastLogin: 2021-01-20 08:26:10username: rootpassword: 123
The source code of C++ test is as follows:
# include # include # include "yaml-cpp/yaml.h" int main () {YAML::Emitter out;out
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.