我复制了"Hello world" code from the website of the GTK project并将其粘贴到 Vim 中,并使用正确配置的 C 语言开发环境 coc-clangd 。但是,在
中显示了几个错误 #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
关于vim - 如何使用 coc-clangd 在 vim 中使用 lib gtk 进行 C 编程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64300017/