ubuntu16.04 升級gcc,g++

昨天編譯caffe時候遇到的,很久沒編譯了,發現現在caffe的版本升級了。用gcc-4.8和g++-4.8都會報錯:

/,libcaffe.so :std :undefined: vectorreference< unsignedto  char`,google :std:::protobufallocator:<:unsignedinternal :char:>StringTypeHandlerBase :>:&,New (std):':
vector.<build_releaseint/,lib /stdlibcaffe.so::: allocatorundefined< int>reference  >to  const`&google):':
protobuf.:build_release:/internallib:/:libcaffe.so:WireFormatLite :undefined: WriteBytesMaybeAliasedreference( intto,  `stdgoogle::::stringprotobuf :const:&internal,: :googleWireFormatLite::::protobufWriteBytesMaybeAliased:(:intio,: :stdCodedOutputStream:*:)string'
const.&build_release,/ libgoogle/:libcaffe.so::protobuf :undefined: ioreference: :toCodedOutputStream *`)leveldb':
:.Statusbuild_release:/:libToString/(libcaffe.so):  constundefined'
reference. build_releaseto/ lib`/leveldblibcaffe.so::: Statusundefined: :referenceToString (to)  `constgoogle':
:.protobufbuild_release:/:libinternal/:libcaffe.so::WireFormatLite :undefined: WriteStringreference( intto,  `stdgoogle::::stringprotobuf :const:&internal,: :googleWireFormatLite::::protobufWriteString:(:intio,: :stdCodedOutputStream:*:)string'
const&, google::protobuf::io::CodedOutputStreamMakefile:640: recipe for target '.build_release/examples/cpp_classification/classification.bin' failed
*)'make: *** [.build_release/examples/cpp_classification/classification.bin] Error 1

make: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
Makefile:635: recipe for target '.build_release/tools/caffe.bin' failed
make: *** [.build_release/tools/caffe.bin] Error 1
Makefile:640: recipe for target '.build_release/examples/mnist/convert_mnist_data.bin' failed
make: *** [.build_release/examples/mnist/convert_mnist_data.bin] Error 1
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() 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::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::string*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const'
.build_release/lib/libcaffe.so: undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::empty_string_'
.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 `cv::imread(std::string const&, int)'
.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::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::StringTypeHandlerBase::Delete(std::string*)'
.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 `cv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> >. build_releaseconst/&examples)/'siamese
/.convert_mnist_siamese_data.obuild_release:/ libIn/ libcaffe.sofunction:  `undefinedconvert_dataset (referencechar  toconst *`,google :char: protobufconst:*:,internal :char: StringTypeHandlerBaseconst:*:)New'(:)
'convert_mnist_siamese_data.cpp
:.(build_release./textlib+/0x4cdlibcaffe.so)::  undefinedundefined  referencereference  toto  ``googleleveldb::::protobufDB::::internalOpen:(:leveldbWireFormatLite::::OptionsWriteBytesMaybeAliased (constint&,,  stdstd::::stringstring  constconst&&,,  googleleveldb::::protobufDB:*:*io):':
CodedOutputStreamconvert_mnist_siamese_data.cpp*:)('.
text.+build_release0x8e7/)lib:/ libcaffe.soundefined:  referenceundefined  toreference  `togoogle :`:leveldbprotobuf::::Statusinternal::::ToStringempty_string_(')
 convert_mnist_siamese_data.cppconst:'(
..textbuild_release+/0x94blib)/:libcaffe.so :undefined  undefinedreference  referenceto  to` google`:google::protobuf::protobuf::MessageLite::internal::SerializeToString:(WireFormatLitestd::::WriteStringstring(*int),  conststd':
:.stringbuild_release /constexamples&/,siamese /google:convert_mnist_siamese_data.o::protobuf :In: iofunction: :`CodedOutputStreamstd*:):'string
* google::MakeCheckOpString<unsigned int, int>(unsigned int const&, int const&, char collect2: error: ld returned 1 exit status
const*)':
convert_mnist_siamese_data.cpp:(.text._ZN6google17MakeCheckOpStringIjiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIjiEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
.build_release/examples/siamese/convert_mnist_siamese_data.o: In function `std::string* google::MakeCheckOpString<unsigned int, unsigned int>(unsigned int const&, unsigned int const&, char const*)':
convert_mnist_siamese_data.cpp:(.text._ZN6google17MakeCheckOpStringIjjEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIjjEEPSsRKT_RKT0_PKc]+0x43): undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() 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 charMakefile:635: recipe for target '.build_release/tools/upgrade_net_proto_text.bin' failed
*)'
.build_releasemake: *** [.build_release/tools/upgrade_net_proto_text.bin] Error 1
/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::string*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const'
.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 `cv::imread(std::string const&, int)'
.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::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::StringTypeHandlerBase::Delete(std::string*)'
.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 `cv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::StringTypeHandlerBase::New()'
.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 `leveldb::Status::ToString() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
collect2: error: ld returned 1 exit status
.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_PKcMakefile:640: recipe for target '.build_release/examples/siamese/convert_mnist_siamese_data.bin' failed
[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKcmake: *** [.build_release/examples/siamese/convert_mnist_siamese_data.bin] Error 1
]+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]+0xb6d): undefined reference to `google::protobuf::internal::empty_string_'
extract_features.cpp:(.text._Z27feature_extraction_pipelineIfEiiPPc[_Z27feature_extraction_pipelineIfEiiPPc]+0x122f): undefined reference to `google::protobuf::MessageLite::SerializeToString(std::string*) const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::InitializationErrorString() 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::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::string*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::GetTypeName() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::Message::DebugString() const'
.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 `cv::imread(std::string const&, int)'
.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::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::StringTypeHandlerBase::Delete(std::string*)'
.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 `cv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::StringTypeHandlerBase::New()'
.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 `leveldb::Status::ToString() const'
.build_release/lib/libcaffe.so: undefined reference to `google::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
collect2: error: ld returned 1 exit status
Makefile:635: recipe for target '.build_release/tools/extract_features.bin' failed
make: *** [.build_release/tools/extract_features.bin] Error 1

查了很多資料,開始說是protoc的故障,但是實驗了一大堆,均沒有解決,最後發現要升級gcc和g++了。具體操作如下:

    cd /usr/bin

    ls -l gcc* cpp g++

發現gcc和g++都是鏈接的4.*版本。確認自己/usr/bin存在5.0版本下。刪除以前的軟連接,執行:

sudo rm /usr/bin/gcc /usr/bin/g++

然後創建新的軟連接:

sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc

sudo ln -s /usr/bin/g++-5 /usr/bin/g++

重新編譯,解決bug.

reference:https://askubuntu.com/questions/372248/downloaded-g-4-8-from-the-ppa-but-cant-set-it-as-default

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章