데비안 Jessie 저장소의 libprotobuf-dev=2.6.0-4
및 protobuf-compiler=2.6.0-4
패키지를 설치했습니다. 이제 MinGW-w64 컴파일러와 함께 Google 개발자 example의 'addressbook.proto'파일을 사용하는 프로그램을 컴파일하려고합니다. 우분투 14.04를 사용하고 있습니다.프로토콜 버퍼가있는 프로그램이 MinGW-w64와 함께 컴파일되지 않습니다. "google :: protobuf :: ...에 대한 정의되지 않은 참조"
:
$ g++ main.cpp addressbook.pb.cc -lprotobuf
하지만 너무 Windows 용 컴파일합니다.
심볼 링크를 추가했습니다 : /usr/include/google
->/usr/i686-w64-mingw32/include/google
. 여전히 작동하지 않는 라이브러리의 위치와
$ i686-w64-mingw32-g++ main.cpp addressbook.pb.cc -lprotobuf
/usr/bin/i686-w64-mingw32-ld: cannot find -lprotobuf
collect2: error: ld returned 1 exit status
:
$ i686-w64-mingw32-g++ -L /usr/lib/i386-linux-gnu/ main.cpp addressbook.pb.cc -lprotobuf
/tmp/ccB1VJyR.o:main.cpp:(.text$_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv[__ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv]+0x7): undefined reference to `google::protobuf::internal::empty_string_'
/tmp/ccB1VJyR.o:main.cpp:(.text$_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv[__ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv]+0x2f): undefined reference to `google::protobuf::internal::empty_string_'
/tmp/ccPz4uiI.o:addressbook.pb.cc:(.text+0x78): undefined reference to `google::protobuf::DescriptorPool::generated_pool()'
/tmp/ccPz4uiI.o:addressbook.pb.cc:(.text+0x87): undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const'
...
감사! 그것은 나를 많이 도왔다! 이것은 나를 위해 일했다 :'./configure --host = i686-w64-mingw32 --prefix =/usr/i686-w64-mingw32 --with-protoc = protoc LDFLAGS = '- static'' – fe173065