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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值