Makefile to Compile OpenCV Code in C++ on Ubuntu/Linux

后端 未结 3 1067
半阙折子戏
半阙折子戏 2021-01-31 05:08

I am learning OpenCV using Learning OpenCV book.

One problem I am facing while compiling the code is that I have to write a long command to compile and get the executabl

3条回答
  •  独厮守ぢ
    2021-01-31 05:49

    Create a file named makefile in your working directory that contains the following:

    CFLAGS = $SHELL(pkg-config --cflags opencv)
    LIBS = $SHELL(pkg-config --libs opencv)
    
    facedetect : facedetect.cpp
        g++ $(CFLAGS) $(LIBS) -o $@ $<
    

    Then when you want to compile you just type:

    $ make
    

    (To answer your PS - note that CMake is very different from make - for now you should probaby just use make.)

提交回复
热议问题