caffe編譯:fatal error: pyconfig.h: No such file or directory #include "pyconfig.h“編譯protobuf
sudo make clean
sudo make all -j8
報錯
CXX tools/caffe.cpp In file included from /usr/include/boost/python/detail/prefix.hpp:13:0, from /usr/include/boost/python/args.hpp:8, from /usr/include/boost/python.hpp:11, from tools/caffe.cpp:2: /usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory # include <pyconfig.h>
原來
ANACONDA_HOME := $(HOME)/anaconda
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python3.6m \
$(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
改為
ANACONDA_HOME := /usr/local/anaconda3 PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ $(ANACONDA_HOME)/include/python3.6m \ $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
新的錯誤
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status Makefile:636: recipe for target '.build_release/tools/upgrade_net_proto_text.bin' failed make: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1 make: *** Waiting for unfinished jobs.... .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status Makefile:636: recipe for target '.build_release/tools/upgrade_net_proto_binary.bin' failed make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1 .build_release/tools/compute_image_mean.o: In function `std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)': compute_image_mean.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/tools/compute_image_mean.o: In function `std::string* google::MakeCheckOpString<unsigned long, int>(unsigned long const&, int const&, char const*)': compute_image_mean.cpp:(.text._ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/tools/compute_image_mean.o: In function `_GLOBAL__sub_I_compute_image_mean.cpp': compute_image_mean.cpp:(.text.startup+0xaf): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' .build_release/tools/compute_image_mean.o: In function `main': compute_image_mean.cpp:(.text.startup+0x15f): undefined reference to `google::SetUsageMessage(std::string const&)' compute_image_mean.cpp:(.text.startup+0x25a): undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' compute_image_mean.cpp:(.text.startup+0x3e9): undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status Makefile:636: recipe for target '.build_release/tools/compute_image_mean.bin' failed make: *** [.build_release/tools/compute_image_mean.bin] Error 1 .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status Makefile:636: recipe for target '.build_release/tools/upgrade_solver_proto_text.bin' failed make: *** [.build_release/tools/upgrade_solver_proto_text.bin] Error 1 .build_release/tools/extract_features.o: In function `std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)': extract_features.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/tools/extract_features.o: In function `std::string* google::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*)': extract_features.cpp:(.text._ZN6google17MakeCheckOpStringImmEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImmEEPSsRKT_RKT0_PKc]+0x44): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/tools/extract_features.o: In function `int feature_extraction_pipeline<float>(int, char**)': extract_features.cpp:(.text._Z27feature_extraction_pipelineIfEiiPPc[_Z27feature_extraction_pipelineIfEiiPPc]+0xc87): undefined reference to `google::protobuf::internal::empty_string_' extract_features.cpp:(.text._Z27feature_extraction_pipelineIfEiiPPc[_Z27feature_extraction_pipelineIfEiiPPc]+0x120d): undefined reference to `google::protobuf::MessageLite::SerializeToString(std::string*) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status Makefile:636: recipe for target '.build_release/tools/extract_features.bin' failed make: *** [.build_release/tools/extract_features.bin] Error 1 .build_release/tools/convert_imageset.o: In function `std::string* google::MakeCheckOpString<unsigned long, int>(unsigned long const&, int const&, char const*)': convert_imageset.cpp:(.text._ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/tools/convert_imageset.o: In function `_GLOBAL__sub_I_convert_imageset.cpp': convert_imageset.cpp:(.text.startup+0x113): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' convert_imageset.cpp:(.text.startup+0x274): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' .build_release/tools/convert_imageset.o: In function `main': convert_imageset.cpp:(.text.startup+0x333): undefined reference to `google::SetUsageMessage(std::string const&)' convert_imageset.cpp:(.text.startup+0xc27): undefined reference to `google::protobuf::MessageLite::SerializeToString(std::string*) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status Makefile:636: recipe for target '.build_release/tools/convert_imageset.bin' failed make: *** [.build_release/tools/convert_imageset.bin] Error 1 .build_release/tools/caffe.o: In function `std::string* google::MakeCheckOpString<cudaError, cudaError>(cudaError const&, cudaError const&, char const*)': caffe.cpp:(.text._ZN6google17MakeCheckOpStringI9cudaErrorS1_EEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringI9cudaErrorS1_EEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/tools/caffe.o: In function `std::string* google::MakeCheckOpString<unsigned long, int>(unsigned long const&, int const&, char const*)': caffe.cpp:(.text._ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/tools/caffe.o: In function `main': caffe.cpp:(.text.startup+0x3e): undefined reference to `google::SetVersionString(std::string const&)' caffe.cpp:(.text.startup+0x6e): undefined reference to `google::SetUsageMessage(std::string const&)' .build_release/tools/caffe.o: In function `_GLOBAL__sub_I_caffe.cpp': caffe.cpp:(.text.startup+0x3e8): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' caffe.cpp:(.text.startup+0x494): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' caffe.cpp:(.text.startup+0x539): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' caffe.cpp:(.text.startup+0x5de): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' caffe.cpp:(.text.startup+0x6b2): undefined reference to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' .build_release/tools/caffe.o:caffe.cpp:(.text.startup+0x757): more undefined references to `google::FlagRegisterer::FlagRegisterer<std::string>(char const*, char const*, char const*, std::string*, std::string*)' follow .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status Makefile:636: recipe for target '.build_release/tools/caffe.bin' failed make: *** [.build_release/tools/caffe.bin] Error 1 .build_release/examples/cpp_classification/classification.o: In function `std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)': classification.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/examples/cpp_classification/classification.o: In function `std::string* google::MakeCheckOpString<unsigned long, int>(unsigned long const&, int const&, char const*)': classification.cpp:(.text._ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void (*)(std::string const&))' .build_release/lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::MessageLite::ParseFromString(std::string const&)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)' .build_release/lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)' .build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() const' collect2: error: ld returned 1 exit status
解除安裝
sudo apt-get autoremove libprotobuf-dev protobuf-compiler
sudo apt-get remove libprotobuf-dev
sudo apt-get remove libprotobuf-compiler
下載https://github.com/protocolbuffers/protobuf
解壓後,進入目錄protobuf-master, 執行:
./autogen.sh
./configure
make
make check
make install
問題1:
./autogen.sh
的時候會提示安裝gmock的Time out,也就是無法下載gmock-1.7.0.zip。
在github上找到了其他的gmock-1.7.0.zip的映象:
gmock-1.7.0.zip下載地址
http://pkgs.fedoraproject.org/repo/pkgs/gmock/gmock-1.7.0.zip/073b984d8798ea1594f5e44d85b20d66/gmock-1.7.0.zip
下完後不用解壓,直接把gmock-1.7.0-master.zip放到protobuf-master的目錄下就ok了。。然後再次執行./autogen.sh。
make check 報錯
configure: WARNING: no configuration information is in third_party/googletest
所以要下載googletest
下載地址:https://github.com/google/googletest/releases
解壓後把googletest放在./protobuf-3.6.1/third_party/googletest
重新
./autogen.sh
這次成功
檢視protof
protoc --version
報錯
protoc: error while loading shared libraries: libprotoc.so.17: cannot open shared object file: No su
解決:
進入到 etc 下
cd /etc-
編輯 ld.so.conf
sudo vim ld.so.conf
在最後加入 libprotoc.so.17的路徑:
/usr/local/lib
儲存之後 再執行如下命令
ldconfig
重新執行protoc --version
最後成功
測試編譯
儲存檔案Helloworld.proto
// Helloworld.proto
syntax = "proto3";
package lm;
message helloworld
{
int32 id = 1;
string str = 2;
}
執行
protoc -I=./ --cpp_out=./ Helloworld.proto
輸 出 Helloworld.pb.h和 Helloworld.pb. cc
新建main.cpp
// main.cpp
#include <iostream>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string>
#include <pthread.h>
#include <fstream>
#include "Helloworld.pb.h"
using namespace std;
#define BUFFSIZE 1024
int main()
{
GOOGLE_PROTOBUF_VERIFY_VERSION; // 寫檔案
lm::helloworld msg1;
msg1.set_id(1);
msg1.set_str("test1");
fstream output("./log", ios::out | ios::trunc | ios::binary);
if (!msg1.SerializeToOstream(&output))
{
cerr << "Failed to write msg." << endl;
return -1;
}
output.close();
cout << msg1.id() << endl;
cout << msg1.str() << endl; // 讀檔案
lm::helloworld msg2;
fstream input("./log", ios::in | ios::binary);
if (!input)
{
cerr << "open file failed!\n";
return -1;
}
if (!msg2.ParseFromIstream(&input)) { cerr << "Parse file failed!" << endl; return -1; }
input.close();
cout << msg2.id() << endl;
cout << msg2.str() << endl; // 寫buf, protobuf序列化
lm::helloworld msg3;
msg3.set_id(2);
msg3.set_str("test2");
char buf[BUFFSIZE];
memset(buf, 0, BUFFSIZE);
msg3.SerializeToArray(buf, BUFFSIZE); //讀buf, protobuf反序列化
lm::helloworld msg4;
msg4.ParseFromArray(buf, BUFFSIZE);
cout << msg4.id() << endl;
cout << msg4.str() << endl;
google::protobuf::ShutdownProtobufLibrary();
return 0;
}
執行
g++ Helloworld.pb.cc main.cpp -o main -lprotobuf -lpthread -std=c++11
輸出main和log
執行./main
輸出
1
test1
1
test1
2
test2
由於上面設定的安裝目錄發生變化,所以我們要修改caffe的makefile.config檔案,在include_dir後面新增 /local_install/include,在library_dir後面新增local_install/bin
在caffe-master有報錯
make clean
make all -j8
:
In file included from /usr/include/c++/4.8/atomic:38:0,
from /usr/local/include/google/protobuf/io/coded_stream.h:113,
from .build_release/src/caffe/proto/caffe.pb.h:23,
from ./include/caffe/util/cudnn.hpp:8,
from ./include/caffe/util/device_alternate.hpp:40,
from ./include/caffe/common.hpp:19,
from ./include/caffe/blob.hpp:8,
from ./include/caffe/layers/cudnn_lcn_layer.hpp:6,
from src/caffe/layers/cudnn_lcn_layer.cu:4:
/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
ref
https://blog.csdn.net/yzhang6_10/article/details/81482852?utm_source=blogxgwz5