• 266阅读
  • 5回复

【求助】能帮忙编译windows Qt环境的protobuf和做例子? [复制链接]

上一主题 下一主题
离线hyluda
 

只看楼主 倒序阅读 楼主  发表于: 04-14
尝试了很多办法,后来看到这个博客:

http://blog.csdn.net/wuyilun2013/article/details/41286867

算式编译出来.a的库,但是用到工程中就报很多undefined reference error.

求大侠帮忙:)很着急,非常感谢!



22:33:16: 正在启动 "C:\mingw32\bin\mingw32-make.exe"

c:\Qt\4.8.6-2\bin\qmake.exe -spec c:\Qt\4.8.6-2\mkspecs\win32-g++ -o Makefile ..\protobuf-component-demo\protobuf-component-demo.proC:/mingw32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'Z:/QtViz/git/demos/build-protobuf-component-demo-unknown-Debug'g++ -mthreads -Wl,-subsystem,windows -o debug\protobuf-component-demo.exe object_script.protobuf-component-demo.Debug  -L"c:\Qt\4.8.6-2\lib" -lmingw32 -lqtmaind -LC:/Users/superadmin/Documents/build-qtproto-unknown-Release/release -lqtproto -lQtGuid4 -lQtCored4
./debug\message.pb.o: In function `ZN17Message_DataArray9MergeFromERKS_':Z:\QtViz\git\demos\build-protobuf-component-demo-unknown-Debug/../../qtdemo/message.pb.cc:672: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)'
Z:\QtViz\git\demos\build-protobuf-component-demo-unknown-Debug/../../qtdemo/message.pb.cc:676: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)'Z:\QtViz\git\demos\build-protobuf-component-demo-unknown-Debug/../../qtdemo/message.pb.cc:680: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)'
./debug\message.pb.o: In function `ZN7Message9MergeFromERKS_':Z:\QtViz\git\demos\build-protobuf-component-demo-unknown-Debug/../../qtdemo/message.pb.cc:1519: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)'
Z:\QtViz\git\demos\build-protobuf-component-demo-unknown-Debug/../../qtdemo/message.pb.cc:1523: undefined reference to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)'./debug\message.pb.o:Z:\QtViz\git\demos\build-protobuf-component-demo-unknown-Debug/../../qtdemo/message.pb.cc:1527: more undefined references to `google::protobuf::internal::ArenaStringPtr::AssignWithDefault(std::string const*, google::protobuf::internal::ArenaStringPtr)' follow
./debug\message.pb.o: In function `CreateInternal<google::protobuf::internal::InternalMetadataWithArena::Container>':c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:640: undefined reference to `google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)'
c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:642: undefined reference to `google::protobuf::Arena::AddListNode(void*, void (*)(void*))'./debug\message.pb.o: In function `CreateInternal<std::basic_string<char> >':
c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:640: undefined reference to `google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)'c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:642: undefined reference to `google::protobuf::Arena::AddListNode(void*, void (*)(void*))'
./debug\message.pb.o: In function `OwnInternal<Message_DataArray>':c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:824: undefined reference to `google::protobuf::Arena::AddListNode(void*, void (*)(void*))'
./debug\message.pb.o: In function `OwnInternal<Message>':c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:824: undefined reference to `google::protobuf::Arena::AddListNode(void*, void (*)(void*))'
./debug\message.pb.o: In function `CreateInternalRawArray<char>':c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:635: undefined reference to `google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)'
./debug\message.pb.o: In function `CreateInternal<Message_DataArray>':c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:640: undefined reference to `google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)'
c:/Users/superadmin/Documents/protobuf-3.0.0/src/google/protobuf/arena.h:642: undefined reference to `google::protobuf::Arena::AddListNode(void*, void (*)(void*))'C:/Users/superadmin/Documents/build-qtproto-unknown-Release/release/libqtproto.a(common.o):common.cc:(.text+0x4c6): undefined reference to `google::protobuf::util::Status::ToString() const'
C:/Users/superadmin/Documents/build-qtproto-unknown-Release/release/libqtproto.a(common.o):common.cc:(.text+0x68d): undefined reference to `google::protobuf::operator<<(std::ostream&, google::protobuf::uint128 const&)'c:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe: C:/Users/superadmin/Documents/build-qtproto-unknown-Release/release/libqtproto.a(common.o): bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit statusMakefile.Debug:159: recipe for target 'debug\protobuf-component-demo.exe' failed
mingw32-make[1]: *** [debug\protobuf-component-demo.exe] Error 1mingw32-make[1]: Leaving directory 'Z:/QtViz/git/demos/build-protobuf-component-demo-unknown-Debug'
Makefile:34: recipe for target 'debug' failedmingw32-make: *** [debug] Error 2
22:33:26: 进程"C:\mingw32\bin\mingw32-make.exe"退出,退出代码 2 。Error while building/deploying project protobuf-component-demo (kit: 桌面)
When executing step "Make"22:33:26: Elapsed time: 00:09.
离线morg

只看该作者 1楼 发表于: 04-15
在protobuf-2.3.0 + vs2015 环境下编译过
离线morg

只看该作者 2楼 发表于: 04-15
项目文件
附件: protobuf.pro (4 K) 下载次数:1
离线sevencat

只看该作者 3楼 发表于: 04-15
也可以用msys2编译好的。
战争就是和平,自由就是奴役,愚味就是力量
离线never_forget

只看该作者 4楼 发表于: 04-15
是. so 文件的引用有问题吗 ?感觉 undefine referance 的大多数情况是库文件的引用不正确呢!

离线hyluda

只看该作者 5楼 发表于: 04-18
不清楚问题呢。 我用mingw+ msys单独编译protobuf通过了,但是放在qt里面,发现mingw+msys的编译器和Qt4.8的编译器(mingw32)不一样。

于是引入protobuf的库,还是undefined reference的问题。

于是我尝试把qt的编译器改成mingw(加msys那个),虽然编译通过了,但qt程序一执行就崩溃。

可能是因为不是用来编译qt4.8.6的mingw的版本的原因?

还在苦苦找寻方案中。。。。

大侠能帮忙提点建议?
快速回复
限100 字节
 
上一个 下一个