1

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)
-lSDL2

Why does this not work for Fish?

3

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')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.