user3459138
user3459138

Reputation: 43

Building C++ with Ninja not parsing file

I'm using sublime text with ubuntu. My build.ninja file looks perfect to me but I get this error when I try build:

ninja
ninja: error: build.ninja:6: expected 'command =' line

Here is my build.ninja file:

cxx = g++
cxxflags = -std=c++20 -Wall -Wextra
builddir = build

rule cxx
    command = mkdir -p $builddir && $cxx $cxxflags -c $in -o $out
    description = Compiling $in

rule link
    command = $cxx $in -o $out
    description = Linking $out

build $builddir/hello.o: cxx hello.cpp
build app: link $builddir/hello.o

default app

Using the cat command in ubuntu we can see the exact line formatting:

cat -A build.ninja

cxx = g++$
cxxflags = -std=c++20 -Wall -Wextra$
builddir = build$
$
rule cxx$
^Icommand = mkdir -p $builddir && $cxx $cxxflags -c $in -o $out$
^Idescription = Compiling $in$
$
rule link$
^Icommand = $cxx $in -o $out$
^Idescription = Linking $out$
$
build $builddir/hello.o: cxx hello.cpp$
build app: link $builddir/hello.o$
$
default app$

Can anyone tell me what the problem could be?

Upvotes: 1

Views: 61

Answers (0)

Related Questions