c++cmeson-buildzig

How do you configure meson to use the zig cc or zig c++ compiler in a build environment for compiling c or c++ code?


I have zig installed under /usr/local/bin/zig, zig version 0.11.0.

I have environment variables $ZIGCC = 'zig cc' and $ZIGCPP = 'zig c++' set in my Fish shell config, and I tried setting my default compiler for a C language project with meson as:

CC=$ZIGCC meson setup build-zig

...for a build directory with zig as the C compiler.

I get this error:

meson.build:1:0: ERROR: Unable to detect linker for compiler `zig cc -Wl,--version -L/usr/local/opt/qt@5/lib -I/usr/local/opt/qt@5/include

I should note /usr/local/opt/qt@5 is a directory on my fish_user_paths environment variable.

I thought zig was a drop-in compiler for gcc and clang. On Makefiles, I could just do:

make CXX=$ZIGCC MyExecutable.exe

or

make CXX=$ZIGCPP MyExecutable.exe

...for C++ and it would just work no need to specify a linker.


Solution

  • workaround for c++:

    for me it work