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

后端 未结 3 1030
半阙折子戏
半阙折子戏 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:45

    GNU Make is pretty smart and the Makefile you need for this doesn't need to be as verbose as in the other answers given so far. Here is a simple Makefile which you can use to compile the OpenCV examples:

    CPPFLAGS = $(shell pkg-config --cflags opencv)
    LDLIBS = $(shell pkg-config --libs opencv)
    

    That's it. The Makefile can be this short thanks to Make's implicit rules.

    Then run make as usual:

    make facedetect
    

    This assumes there is a facedetect.c or facedetect.cpp in the same directory.

    I recommend the following (free!) book if you want to learn Make: http://oreilly.com/catalog/make3/book/index.csp

提交回复
热议问题