1
gcc로 우분투 16.04를 실행하고 있습니다.protobuf의 컴파일이 D_GLIBCXX_USE_CXX11_ABI = 0과 함께 실패합니다.
g++ -D_GLIBCXX_USE_CXX11_ABI=0 q.cpp -L/usr/lib/x86_64-linux-gnu /usr/local/lib/libprotobuf.a -lpthread
protoc --version
반환 :
내 q.ccp
파일은 컴파일에 사용
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/descriptor.h>
int main(int argc, char **argv)
{
google::protobuf::Message* msg;
const google::protobuf::Descriptor* message_desc = msg->GetDescriptor();
const google::protobuf::FieldDescriptor * fd_name = message_desc->FindFieldByName("name");
return 0;
}
명령입니다 2.2.0
GCC는 --version
gcc (Ubuntu 4.8.5-4ubuntu2) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
컴파일 오류 :
/tmp/cciGJPqq.o: In function `main':
q.cpp:(.text+0x5f): undefined reference to `google::protobuf::Descriptor::FindFieldByName(std::string const&) const'
collect2: error: ld returned 1 exit status
하지만이 -D_GLIBCXX_USE_CXX11_ABI=0
옵션을 떠날 때, 나는 어떤 컴파일 오류가 발생하지 않습니다. 그러나 문제는 프로그램 실행을 위해이 옵션을 사용하여 컴파일해야하는 다른 시스템에서 실행 파일을 실행하고 있다는 것입니다.
[정의되지 않은 참조/확인되지 않은 외부 기호 오류 란 무엇이며 어떻게 해결할 수 있습니까?] (http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved- 외부 기호 오류 및 어떻게해야합니까 - 수정) – Danh
@ 대장, 자, 사람, 적어도 전체 질문을 읽어보십시오. 너 정말 진심이야? – v78
나는 내 결정을 바꾸지 않을 것이다. g ++은 ABI를 변경 시켰고, 당신의 프로그램은 당신의 라이브러리와 같은 ABI로 컴파일 될 필요가있다. – Danh