如何在不使用 CMake 的情况下构建 yaml-cpp
我需要使用 yamp-cpp 进行大学项目。为此,我计划将 yamp-cpp 的源代码包含在“lib”文件夹中,以便能够构建库,然后构建我的项目。
问题是我无法使用 CMake(无法在我将演示项目的地方安装它),并且我不知道如何从命令行(或 makefile)构建这个库。
我已经从命令行构建了简单的 C++ 程序,但我无法正常工作(尝试检查 CMake 的输出,但它很大)
任何人都可以告诉我需要执行的行才能构建库然后链接它比如说,一个示例 main.cpp?
提前致谢。
I need to use yamp-cpp for a university project. For that, i plan to include the sources of yamp-cpp in a "lib" folder to be able to build the library and then my project.
The thing is that i cannot use CMake (can't install it where i will be demoing the project), and i dont know how to build this lib from command line (or makefile).
I've built simple c++ programs from command line, but i cannot get this working (tried to inspect the output from CMake but it is huge)
Can anyone tell me the lines i need to execute in order to build the lib and then link it to, say, a sample main.cpp?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要做的就是将所有 .cpp 文件添加到 makefile 中。 CMake 文件没有做任何特殊的事情。
确保标题对您的项目可见。公共标头全部包含为
"yaml-cpp/foo.h"
(因此,根据您放置yaml-cpp
文件夹的位置,确保其父目录位于您的包含路径。私有标头包含为"foo.h"
,因此请确保它们的文件夹也在您的包含路径中。All you need to do is add all .cpp files to your makefile. The CMake file doesn't do anything special.
Be sure that the headers are visible to your project. The public headers are all included as
"yaml-cpp/foo.h"
(so depending on where you put theyaml-cpp
folder, make sure its parent directory is in your include path. The private headers are include as"foo.h"
, so make sure that their folder is also in your include path.