Category Archives: C++

总结CMake

本文参考 知乎回答:https://www.zhihu.com/question/58949190/answer/999701073 如何写CMakeList.txt C++工程的setup Learn CMake’s Scripting Language in 15 Minutes 入门 CMake的目的:It’s all about targets Define a target: defines targets using the add_executable, add_library or add_custom_target commands. Define the target’s properties: Once a target is created, it has properties that you can manipulate using the get_property and set_property commands.  All target properties are strings. In CMake, every variable is a string.  Other target properties include LINK_LIBRARIES, INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS. Those…

Read More

CMakeList.txt: 六个例子

我们已经在C++工程的setup提到过,CMake是build system的生成器,它用于生成makefile,然后make就可以使用生成的make file对c++工程进行编译和链接成可执行文件。The make utility and Makefiles provide a build system that can be used to manage the compilation and re-compilation of programs that are written in any programming language. I use Makefiles quite often in my projects to automate the build process; however, there are times when Makefiles become overly complex for the task. Building complex projects is…

Read More

CMake-based C++工程

本文参考medium作者Aakash Mallik关于c++开发的文章。 1. https://medium.com/heuristics/c-application-development-part-1-project-structure-454b00f9eddc2. https://medium.com/heuristics/c-application-development-part-2-cmakelists-txt-e415b5b387dc3. https://medium.com/heuristics/c-application-development-part-3-cmakelists-txt-from-scratch-7678253e5e244. https://www.learncpp.com/cpp-tutorial/a1-static-and-dynamic-libraries/5. https://medium.com/@onur.dundar1/cmake-tutorial-585dd180109b6. https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/ 在开发C++大工程时,有两件事情要注意: Maintaining a project structure Dealing with third-party libraries 关注第一件事情:Maintaining a project structure 通常的c++工程结构如下: CMakeLists.txt include文件夹 src文件夹 libs文件夹 tests文件夹。 include文件夹 传统上,include文件夹是用于放header files, 但是modern practice 建议include文件夹必须strictly contain headers that need to be exposed publicly. 我们在include文件夹下,还特地加了一个与project名字相同的文件夹。这样做的目的是,由于include文件夹主要是为了方便外用的(供别人调用你写的这个library),所以我么希望当别人调用该project用于外用时是这样的:#include <Project_Name/public_header.h>,而不是#include <public_header.h>的。 src文件夹 src文件夹包含所有的源代码,以及所有那些仅用于internal use的header files。基本上,如果你注意third-party libraries时,基本都有类似的结构。 libs文件夹 libs文件夹包含了所有我们需要用到的third-party libraries。通常我们有两种方式来使用third-party libraries in C++:Static或者Dynamic。libs文件夹只包含通过static方式使用的third-party libraries。…

Read More

HPP, FCL and Pinocchio

FCL(Flexible Collision Library) FCL是Flexible Collision Library的缩写,是A General Purpose Library for Collision and Proximity Queries,它具体的github repo在这里,相关的学术文章为FCL: A general purpose library for collision and proximity queries。 FCL is also used as the collision checking library for grasping and manipulation pipeline implemented on a PR2. In the course of the task, the overall algorithm makes multiple calls to…

Read More

C++知识点

GCC vs. Clang/LLVM: An In-Depth Comparison of C/C++ Compilers Clang on macOS (Using Clang in Visual Studio Code, Compile and debug) Using C++ on Linux in VS Code(Compile and debug) CMake Tools on Linux TOP 70 C++ Interview Questions And Answers C++来读写文件 The standard input默认是keyboard,The standard output默认是the screen, 于是就要用到standard C++ library:#include <iostream>。其中的cin和cout的函数(endl是结束本行并换行)。 那么如果我们想从读某个文件或者写一个文件呢?也就是输入和输出不是标准的输入和输出。这是由我们要另一个standard C++ library: fstream。 #include…

Read More