c项目生成compile_commands.json

一、生成compile_commands.json

1.1、compile_commands.json内容

cmake生成compile_commands.jsons

https://blog.csdn.net/qq_23599965/article/details/90697236

方法
CMakeList.txt在Main文件夹下,

cd main
mkdir build
cd build
cmake ../Main -DCMAKE_EXPORT_COMPILE_COMMANDS=1

提取结果

[
    {
      "directory": "/root/data/clang-llvm/TestProject/build",
      "command": "/bin/c++  -I/root/data/clang-llvm/TestProject/Main/include  -o CMakeFiles/t.dir/t.cpp.o -c /root/data/clang-llvm/TestProject/Main/t.cpp",
      "file": "/root/data/clang-llvm/TestProject/Main/t.cpp"
    }
]

1.2、bear生成compile_commands.json

以bash为例子
代码仓库
https://git.savannah.gnu.org/cgit/bash.git

mkdir build
cd build
bear -- ../configure --prefix=//media/data/clang-llvm/bash/build
bear -- make

原文链接: https://www.cnblogs.com/xine/p/16689250.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    c项目生成compile_commands.json

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/190921

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午4:39
下一篇 2023年2月12日 下午4:41

相关推荐