c++ - 如何为 visual studio 2013 安装 YAML-cpp?

标签 c++ visual-studio-2013 yaml

如何安装用于 visual studio 2013 的 YAML-cpp 库?

我已经下载了 CMake(不知道如何使用它)和 YAML 源文件,并尝试按照网站上的说明进行操作,但在第 2 步时卡住了。

我看过How to install and use YAML-Cpp ,但它并没有真正详细说明如何去做。

我已经导航到其中包含下载的 YAML-cpp 文件的目录,但是当我将该文件添加到 CMake 列表时,它是红色的,并且在我尝试配置它时抛出很多错误

CMake Error: Cannot open file for write: C:/Program Files (x86)/CMake/CMakeCache.txt.tmp
CMake Error: The source directory "C:/Program Files (x86)/CMake/source" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
CMake Error: : System Error: No such file or directory
CMake Error: Unable to open cache file for save. C:/Program Files (x86)/CMake/CMakeCache.txt
CMake Error: : System Error: No such file or directory

我做错了什么?

最佳答案

project page here 上有关于您必须做什么的公平描述。但更具体地说,这部分:

How to Build yaml-cpp uses CMake to support cross-platform building. The basic steps to build are:

Download and install CMake (Resources -> Download). Note: If you don't use the provided installer for your platform, make sure that you add CMake's bin folder to your path.

  1. Navigate into the source directory, and type: mkdir build cd build
  2. Run CMake. The basic syntax is: cmake [-G generator] [-DBUILD_SHARED_LIBS=ON|OFF]

..The generator is whatever type of build system you'd like to use. To see a full list of generators on your platform, just run cmake (with no arguments). For example:

  • On Windows, you might use "Visual Studio 12 2013" to generate a Visual Studio 2013 solution.
  • On OS X, you might use "Xcode" to generate an Xcode project.

  • On a UNIX-y system, simply omit the option to generate a makefile.

yaml-cpp defaults to building a static library, but you may build a shared library by specifying -DBUILD_SHARED_LIBS=ON.

For more options on customizing the build, see the CMakeLists.txt file.

Build it!

To clean up, just remove the build directory.

因此您可以将它用作项目中的静态库,您可以像往常一样使用所有方法。

或者,您可以跳过所有 cMake 内容,只需将所有 .h 和 .cpp 文件复制到项目中的一个文件夹中,然后像引用任何其他代码一样引用它,缺点是您必须复制和维护大约 20-30 个文件可能会随着人们对项目的投入而改变

关于c++ - 如何为 visual studio 2013 安装 YAML-cpp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26383068/

相关文章:

c++ - 如果我不释放/删除动态分配的数组会发生什么?

c# - 缺少 DocumentFormat.OpenXml.Extensions

visual-studio-2013 - Visual Studio编辑器中的不同线高

visual-studio - 从 VS2010 升级到 VS2013 现在我无法发布

azure-devops - 如何命名管道?

c++ - 使用glew绘制函数做离屏渲染

c++ - 如何存储需要随机挑选和删除的数据, vector ,哈希表或其他?

c++ - 如何在 C++ 中解决这个 for 循环?

ruby - Perl 和 Ruby 之间的 YAML 数据交换问题

kubernetes - Kubernetes configmaps 中的自动子目录?