1.首先需要搭配好caffe的运行环境,可参考我另一篇博客:http://blog.youkuaiyun.com/llwjason5555/article/details/62424085
2.打开codeblocks,建立工程,右击工程,选择Build options,Linker setting左边添加opencv动态库和/caffe/build/lib/libcaffe.so,右边添加
-pthread
-lcaffe -lglog -lgflags -lprotobuf -lboost_system -lboost_filesystem
-lm -lleveldb -lsnappy -llmdb -lboost_thread
-lstdc++ -lcblas -latlas
3.Search directories->Compiler: opencv中include路径和/caffe/include, /caffe/build/src
4.Search directories->Linker: opencv中lib库路径和/caffe/build/lib
5.Compiler setting->#define,添加
CPU_ONLY
USE_OPENCV
USE_LEVELDB
USE_LMDB
5.编写调用caffe模型的程序即可运行
备注:我搭建的是CPU环境下的caffe