如何安装用于 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.
- Navigate into the source directory, and type:
mkdir build cd build
- 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/