오랫만에 빌드하니 다 까먹었네 -_ㅠ
g++ myprog.cpp -lopencv_core -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -o myprog
[링크 : https://answers.opencv.org/question/165673]
아놔.. 에러 뿜뿜 -_-
/usr/bin/ld: warning: libopencv_imgproc.so.3.4, needed by //usr/local/lib/libopencv_dnn.so, may conflict with libopencv_imgproc.so.3.2
/usr/bin/ld: warning: libopencv_core.so.3.4, needed by //usr/local/lib/libopencv_dnn.so, may conflict with libopencv_core.so.3.2
/usr/bin/ld: /tmp/cc64nD60.o: undefined reference to symbol '_ZNK2cv3Mat5emptyEv'
/usr/bin/ld: //usr/local/lib/libopencv_core.so.3.4: error adding symbols: DSO missing from command line
+
아무튼 라즈베리 3B 에서 하는데
3.2.0이 설치되어 있고, 필요에 의해서 3.4.0을 빌드해서 설치했더니 3.2.0과 섞여서 난리가 났다.
그래서 -L 옵션을 통해 3.4.0이 설치된 곳을 우선적으로 보도록 해주니 문제없이 해결!
$ whereis libopencv_imgproc
libopencv_imgproc: /usr/lib/arm-linux-gnueabihf/libopencv_imgproc.so /usr/lib/arm-linux-gnueabihf/libopencv_imgproc.a /usr/local/lib/libopencv_imgproc.so
$ ls -al /usr/local/lib/libopencv_imgproc.so*
lrwxrwxrwx 1 root root 24 Jan 14 08:04 /usr/local/lib/libopencv_imgproc.so -> libopencv_imgproc.so.3.4
lrwxrwxrwx 1 root root 27 Jan 14 08:04 /usr/local/lib/libopencv_imgproc.so.3.4 -> libopencv_imgproc.so.3.4.13
-rw-r--r-- 1 root root 3292320 Jan 14 05:01 /usr/local/lib/libopencv_imgproc.so.3.4.13
$ ls -al /usr/lib/arm-linux-gnueabihf/libopencv_imgproc.so
lrwxrwxrwx 1 root root 24 Feb 12 2019 /usr/lib/arm-linux-gnueabihf/libopencv_imgproc.so -> libopencv_imgproc.so.3.2
$ g++ opencv_video.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib
MobileNet-SSD의 ssd_detect.cpp 빌드하려다가
아 몰라 대충 흑화중.. 후...
sudo apt-get install libcaffe-cpu-dev libcaffe-cpu1 libboost-all-dev libgflags-dev libgoogle-glog-dev libprotobuf-dev libopenblas-dev
$ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect
ssd_detect.cpp:15:10: fatal error: caffe/caffe.hpp: No such file or directory
#include <caffe/caffe.hpp>
^~~~~~~~~~~~~~~~~
compilation terminated.
pi@raspberrypi:~/src/MobileNet-SSD $ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect
In file included from /usr/include/caffe/blob.hpp:8,
from /usr/include/caffe/caffe.hpp:7,
from ssd_detect.cpp:15:
/usr/include/caffe/common.hpp:4:10: fatal error: boost/shared_ptr.hpp: No such file or directory
#include <boost/shared_ptr.hpp>
^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
pi@raspberrypi:~/src/MobileNet-SSD $ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect
In file included from /usr/include/caffe/blob.hpp:8,
from /usr/include/caffe/caffe.hpp:7,
from ssd_detect.cpp:15:
/usr/include/caffe/common.hpp:5:10: fatal error: gflags/gflags.h: No such file or directory
#include <gflags/gflags.h>
^~~~~~~~~~~~~~~~~
compilation terminated.
$ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect
In file included from /usr/include/caffe/common.hpp:19,
from /usr/include/caffe/blob.hpp:8,
from /usr/include/caffe/caffe.hpp:7,
from ssd_detect.cpp:15:
/usr/include/caffe/util/device_alternate.hpp:34:10: fatal error: cublas_v2.h: No such file or directory
#include <cublas_v2.h>
^~~~~~~~~~~~~
compilation terminated.
-DCPU_ONLY
$ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect -DCPU_ONLY
In file included from /usr/include/caffe/util/math_functions.hpp:11,
from /usr/include/caffe/filler.hpp:13,
from /usr/include/caffe/caffe.hpp:9,
from ssd_detect.cpp:15:
/usr/include/caffe/util/mkl_alternate.hpp:14:10: fatal error: cblas.h: No such file or directory
#include <cblas.h>
^~~~~~~~~
compilation terminated.
$ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect -DCPU_ONLY -lcaffe
/usr/bin/ld: /tmp/ccDNrn3i.o: undefined reference to symbol '_ZN6google4base21CheckOpMessageBuilder7ForVar2Ev'
/usr/bin/ld: //lib/arm-linux-gnueabihf/libglog.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
$ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect -DCPU_ONLY -lcaffe -lglog
/usr/bin/ld: /tmp/ccO8VjqT.o: undefined reference to symbol '_ZN6google26ShowUsageWithFlagsRestrictEPKcS1_'
/usr/bin/ld: //lib/arm-linux-gnueabihf/libgflags.so.2.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
$ g++ ssd_detect.cpp -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_videoio -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -L/usr/local/lib -o ssd_detect -DCPU_ONLY -lcaffe -lgflags -lglog
/usr/bin/ld: warning: libopencv_imgcodecs.so.3.2, needed by /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/libcaffe.so, may conflict with libopencv_imgcodecs.so.3.4
/usr/bin/ld: warning: libopencv_imgproc.so.3.2, needed by /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/libcaffe.so, may conflict with libopencv_imgproc.so.3.4
/usr/bin/ld: warning: libopencv_core.so.3.2, needed by /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/libcaffe.so, may conflict with libopencv_core.so.3.4
caffe 빌드
위에 lib들 설치하고 아래것 추가로 설치
sudo apt-get install protobuf-compiler libhdf5-dev liblmdb-dev libleveldb-dev libatlas-base-dev python-numpy |