I have fish shell installed as the default shell on my fedora machine. I recently switched to nvim and I am using deoplete-clang2 for autocomplete.
But it's only completing the names of the header files. So based on this issue I tried creating a compile_commands.json
file.
[
{
"directory" : "/mnt/Work/Learn/Gtk/Official",
"command" : " /usr/bin/bash echo \"/usr/bin/clang (pkg-config --cflags gtk+-3.0) -o main main.c (pkg-config --libs gtk+-3.0)\"",
"file" : "/mnt/Work/Learn/Gtk/Official/main.c"
}
]
But when I run clang-check main.c
to verify the commands the following errors are thrown.
error: unsupported option '--cflags'
error: unsupported option '--libs'
warning: (pkg-config: 'linker' input unused [-Wunused-command-line-argument]
warning: gtk+-3.0): 'linker' input unused [-Wunused-command-line-argument]
warning: (pkg-config: 'linker' input unused [-Wunused-command-line-argument]
warning: gtk+-3.0): 'linker' input unused [-Wunused-command-line-argument]
In file included from main.c:2:
/usr/include/gtk-3.0/gtk/gtk.h:30:10: fatal error: 'gdk/gdk.h' file not found
#include <gdk/gdk.h>
^~~~~~~~~~~
1 error generated.
Error while processing /mnt/Work/Learn/Gtk/Official/main.c.
So how do I fix this. Thanks
This is explicitly executing bash , not fish.
"command" : " /usr/bin/bash echo \"[...]
You can change that by using "/usr/bin/fish" instead of bash (adjust the path if that's not where you have installed fish).
Alternatively, you just need to change the ()
to $()
- that's where the error comes from. command1 (command2 arg1 arg2)
isn't valid syntax in bash, and will just be passed as-is to command1 (ie it'll receive (command2
, arg1
and arg2)
as its arguments).
Change it to
"command" : " /usr/bin/bash echo \"/usr/bin/clang $(pkg-config --cflags gtk+-3.0) -o main main.c $(pkg-config --libs gtk+-3.0)\""
and it should work. (Note the $
s)
If you do decide to use fish, note that pkg-config
expects its output to be split on spaces, which fish doesn't do (only newlines). So you'd need to pipe it to string split " "
, like
(pkg-config --libs gtk+-3.0 | string split " ")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.