如何在带有coc-clangd的vim中使用lib gtk在C中编程?

问题描述

我从gtk项目的网站复制了hello world代码,然后将其粘贴到环境中的vim中,以便在用coc-clangd正确配置的C中进行开发。但是,

#include <gtk / gtk.h>

但是当我使用命令发送编译时:

gcc `pkg-config --cflags gtk+-3.0` -o hello-world-gtk hello-world-gtk.c `pkg-config --libs gtk+-3.0`

它完美地工作 我试图添加

`pkg-config --cflags gtk+-3.0`

clangd.fallbackFlags

在:CocConfig中,但无效。

解决方法

https://clangd.llvm.org/troubleshooting.html

https://sarcasm.github.io/notes/dev/compilation-database.html

clang -MJ hello-world-gtk.o.json `pkg-config --cflags gtk+-3.0` -o hello-world-gtk hello-world-gtk.c `pkg-config --libs gtk+-3.0`

sed -e '1s/^/[\n/' -e '$s/,$/\n]/' *.o.json > compile_commands.json