background
If Caffe is compiled with cmake and protobuf of a lower version (such as 2.5) is used, an error will be reported. Cmake cannot find protobuf
Solution:
Change the default cmake file of Caffe project and use PKG config to find it
Solution:
Modify the cmake file with error. The path is cmake/protobuf.Cmake
under Cafe project. Modify the following two places
# Finds Google Protocol Buffers library and compilers and extends
# Modified 1:
########################
# Use pkg-config to find packages instead
set(ENV{PKG_CONFIG_PATH} /home/timber/Library/lib/pkgconfig)
#find_package( Protobuf REQUIRED )# comment out
find_package(PkgConfig)
pkg_search_module( Protobuf REQUIRED protobuf)
#########################
list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${PROTOBUF_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS PUBLIC ${PROTOBUF_LIBRARIES})
# As of Ubuntu 14.04 protoc is no longer a part of libprotobuf-dev package
# and should be installed separately as in: sudo apt-get install protobuf-compiler
if(EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
message(STATUS "Found PROTOBUF Compiler: ${PROTOBUF_PROTOC_EXECUTABLE}")
else()
message(FATAL_ERROR "Could not find PROTOBUF Compiler")
endif()
# Modified 2:
##########################
# Forcibly set to ON
set(PROTOBUF_FOUND ON)
if(PROTOBUF_FOUND)
##########################
# fetches protobuf version
caffe_parse_header(${PROTOBUF_INCLUDE_DIR}/google/protobuf/stubs/common.h VERION_LINE GOOGLE_PROTOBUF_VERSION)
string(REGEX MATCH "([0-9])00([0-9])00([0-9])" PROTOBUF_VERSION ${GOOGLE_PROTOBUF_VERSION})
set(PROTOBUF_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
unset(GOOGLE_PROTOBUF_VERSION)
endif()
# place where to generate protobuf sources
set(proto_gen_folder "${PROJECT_BINARY_DIR}/include/caffe/proto")
include_directories("${PROJECT_BINARY_DIR}/include")
set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE)
Similar Posts:
- caffe35793;- 38382;- 39064;src/caffe/net. cpp:8 :18: fatal error: hdf5.h: No such file or directory compilation term…
- Cmake: How to Connect boost Library
- Caffe Install ImportError: No module named google.protobuf.internal
- The C compiler identification is unknown No CMAKE_C_COMPILER could be found
- Centos7 Install MYSQL Error: Could NOT find Curses (missing CURSES_LIBRARY CURSES_INCLUDE_PATH)
- CMake: How to Complie Log4cplus
- Solution of import Cafe error reporting in Python command line
- [Solved] –go_out: protoc-gen-go: Plugin failed with status code 1.
- [How to Solve] protoc: Command not found
- [Solved] Grpc Error: unable to determine Go import path for