{Makefile Error} “commands commence before first target. Stop.”

后端 未结 2 538
花落未央
花落未央 2020-12-12 03:59

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 wit

相关标签:
2条回答
  • 2020-12-12 04:53

    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

    0 讨论(0)
  • 2020-12-12 04:57

    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
    
    0 讨论(0)
提交回复
热议问题