Issue
I tried several commands in zsh:
# 1 work
echo `pkg-config --version`
# 2 work
echo $(pkg-config --version)
# 3 not work: pkg-config command not found
echo `pkg‑config ‑‑cflags ‑‑libs glib‑2.0`
# 4 work
echo $(pkg-config --cflags --libs glib-2.0)
# 5 not work: pkg-config command not found
gcc $(pkg‑config ‑‑cflags ‑‑libs glib‑2.0) ‑o test test.c
# 6 work
gcc test.c ‑o test $(pkg‑config ‑‑cflags ‑‑libs glib‑2.0)
# 7 not work: pkg-config command not found
gcc `pkg‑config ‑‑cflags ‑‑libs glib‑2.0` ‑o test test.c
# 8 work
gcc test.c ‑o test `pkg‑config ‑‑cflags ‑‑libs glib‑2.0`
Why does no.3 not work while no.4 can? Why do I have to put the shell constitution at the end for gcc (no. 4-8)? Is it caused by my shell settings?
Solution
I think you may need to check the dash -
. (not ‑
)
# 3 not work: pkg-config command not found
echo `pkg‑config ‑‑cflags ‑‑libs glib‑2.0`
# ^ here ^^ ^^ ^ and these
# 4 work
echo $(pkg-config --cflags --libs glib-2.0)
# ^ This one is the correct one.
Answered By - ktc Answer Checked By - Marilyn (WPSolving Volunteer)