Fish's command substitution is supposed to be the equivalent of Bash's $() yet this simple example fails:

g++ -std=c++14 -Wall -Wextra -pedantic -g (pkg-config --cflags sdl2) \
    test.cpp (pkg-config --libs sdl2)
/usr/bin/ld: cannot find -lSDL2

If I run it in Bash, it works perfectly fine. Also typing -lSDL2 instead of using pkg-config works as well.

To clarify, there's nothing wrong with pkg-config:

echo (pkg-config --libs sdl2)

Why does this not work for Fish?

1 Answer 1


This is a known issue in Fish, #982. Apparently they want you to use eval or to parse the output to convert the spaces to newlines:

eval g++ -o code code.cc (pkg-config opencv --cflags --libs)
g++ -o code code.cc (pkg-config opencv --cflags --libs | perl -pe 's/\s+/\n/g')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .