{Makefile Error} "commands commence before first target. Stop."
Asked Answered
H

2

1

I'm trying to produce a makefile for use with my Raspberry Pi, the intention is to use the Pi's camera board to detect faces with opencv. However I keep facing myself with the following error:

Makefile:12: *** commands commence before first target.  Stop.

I use the following makefile:

FLAGS = 'pkg-config --cflags opencv --libs opencv'
CC = g++
HOME = /home/pi
LDFLAGS_CAMCV = -L$(HOME)/git/robidouille/raspicam_cv -lraspicamcv
LDFLAGS_USER =-L$(HOME)/git/raspberrypi/userland/build/lib -lmmal_core -lmmal -$
LDFLAGS_FACE = -l$(HOME)/git/emobot/libfacere0.04
LDFLAGS = $(LDFLAGS_CAMCV) $(LDFLAGS_USER)  $(LDFLAGS_FACE)
INCLUDE = -I$(HOME)/git/robidouille/raspicam_cv
        $(CC) -o emobot_test.exe:  main.cpp $(INCLUDE) $(LDFLAGS)

LDFLAGS_CAMCV and LDFLAGS_USER are required for the raspicamcv library and INCLUDE is the associated header file. LDFLAGS_FACE is needed to detect faces in opencv2.3 as 2.4 is currently unsupported by the Pi.

I'm certain this error is incredibly trivial however clear documentation about makefiles is few and far between if anyone can provide a solution I would be grateful.

Hayashi answered 20/1, 2014 at 15:46 Comment(3)
Isn't 12 the line number? Which line is line 12? (And for that matter, you've got commands on the last line posted here, which are before any target. Which target do you want those commands to go with?)Sanguinaria
You should use a target pattern.Hawk
The GNU make manual documentation is quite clear, certainly for the basics: gnu.org/software/make/manual/html_node/index.htmlBartholemy
H
3

Smth like:

FLAGS = 'pkg-config --cflags opencv --libs opencv'
CC = g++
HOME = /home/pi
LDFLAGS_CAMCV = -L$(HOME)/git/robidouille/raspicam_cv -lraspicamcv
LDFLAGS_USER =-L$(HOME)/git/raspberrypi/userland/build/lib -lmmal_core -lmmal -$
LDFLAGS_FACE = -l$(HOME)/git/emobot/libfacere0.04
LDFLAGS = $(LDFLAGS_CAMCV) $(LDFLAGS_USER)  $(LDFLAGS_FACE)
INCLUDE = -I$(HOME)/git/robidouille/raspicam_cv

all: emobot_test

emobot_test:
tab$(CC) -o emobot_test.exe  main.cpp $(INCLUDE) $(LDFLAGS)

<tab> is a literal keypress, donna how to insert it in the answer field.

Explanation:
$(CC) -o emobot_test... is a command which should be executed upon a target invocation.

all is the default target which is executed when you simply run make without parameters.

all depends on emobot_test target emobot_test doesn't depend on any target but always runs $(CC) -o emobot_test... for completion

Hawk answered 20/1, 2014 at 15:50 Comment(0)
P
0

I had the same issue ...

I already have rules for check, test and build... but wanted to string them together...

Easy I thought...

.DEFAULT_GOAL := fullcheck
    $(MAKE) check
    $(MAKE) test
    $(MAKE) build

But no commands commence before first target. Stop.

What I had omitted was, the name of the rule. It should be like this.

.DEFAULT_GOAL := fullcheck
fullcheck:
    $(MAKE) check
    $(MAKE) test
    $(MAKE) build
Picasso answered 19/2, 2020 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.