gpt4 book ai didi

c++ - 交叉编译Qt to Raspberry Pi 3B+ addressbook (Protocol Buffer) - error symbol lookup error

转载 作者:太空宇宙 更新时间:2023-11-04 12:30:53 29 4
gpt4 key购买 nike

我正在从 Qt (Ubuntu 19.10 - 5.12.3) 交叉编译到 Raspberry Pi 3B+ (stetch)。我已经成功做到了,我能够运行从 Qt 到 Raspberry 的应用程序。

现在我想使用通过 protoc( Protocol Buffer )获得的 .h 和 .cc 文件部署和执行应用程序。

所以首先我在我的笔记本电脑上安装了 Protocol Buffer 3.10.1...我创建了 .h 和 .cc 文件然后在 Qt 中我将它们添加到我的项目中( untitled.pro).

在我用这个配置重复操作之后:

./configure --host=arm-linux CC=/home/belfix/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc CXX=/home/belfix/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++

通过这种方式,我获得了树莓派所需的 libprotobuf.a...在 Qt untitled.pro 中,我添加了以下行:

unix:!macx: LIBS += -L$$PWD/../../../usr/local/lib/ -lprotobuf

INCLUDEPATH += $$PWD/../../../usr/local/include
DEPENDPATH += $$PWD/../../../usr/local/include

unix:!macx: PRE_TARGETDEPS += $$PWD/../../../usr/local/lib/libprotobuf.a

程序构建和部署但是......当我按运行时我遇到了这个错误

/home/pi/untitled/bin/untitled: symbol lookup error:/home/pi/untitled/bin/untitled: undefined symbol: _ZN6google8protobuf8internal26fixed_address_empty_stringE

我该如何解决?

在 Raspberry 中我试过:ldd -d -r untitled

linux-vdso.so.1 (0x7ef7d000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76ee8000)
libprotobuf.so.21 => /usr/local/lib/libprotobuf.so.21 (0x76c9d000)
libQt5Widgets.so.5 => /usr/local/qt5pi/lib/libQt5Widgets.so.5 (0x76770000)
libQt5Gui.so.5 => /usr/local/qt5pi/lib/libQt5Gui.so.5 (0x762b8000)
libQt5Mqtt.so.5 => /usr/local/qt5pi/lib/libQt5Mqtt.so.5 (0x76288000)
libQt5Network.so.5 => /usr/local/qt5pi/lib/libQt5Network.so.5 (0x7610b000)
libQt5Core.so.5 => /usr/local/qt5pi/lib/libQt5Core.so.5 (0x75ba1000)
libGLESv2.so.2 => /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2 (0x75b7c000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x75b53000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x75a0b000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x7598c000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x7595f000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x75820000)
libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0x757f9000)
/lib/ld-linux-armhf.so.3 (0x76efe000)
libpng16.so.16 => /usr/lib/arm-linux-gnueabihf/libpng16.so.16 (0x757bf000)
libdouble-conversion.so.1 => /usr/lib/arm-linux-gnueabihf/libdouble-conversion.so.1 (0x7579d000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x7578a000)
libgthread-2.0.so.0 => /usr/lib/arm-linux-gnueabihf/libgthread-2.0.so.0 (0x75778000)
libglib-2.0.so.0 => /lib/arm-linux-gnueabihf/libglib-2.0.so.0 (0x75670000)
libbrcmEGL.so => /opt/vc/lib/libbrcmEGL.so (0x75637000)
libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x7560e000)
libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x755f8000)
libvcos.so => /opt/vc/lib/libvcos.so (0x755df000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x755c8000)
libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0x7554f000)
undefined symbol: _ZN6google8protobuf8internal26fixed_address_empty_stringE (./untitled)
undefined symbol: _ZNK6google8protobuf7Message25InitializationErrorStringEv (./untitled)
undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv (./untitled)
undefined symbol: _ZN6google8protobuf8internal24InlineGreedyStringParserEPSsPKcPNS1_12ParseContextE (./untitled)
undefined symbol: _ZN6google8protobuf2io19EpsCopyOutputStream30WriteStringMaybeAliasedOutlineEjRKSsPh (./untitled)

最佳答案

尝试将其添加到您的 .pro 文件中。

DEFINES += PROTOBUF_USE_DLLS

实际上您正在链接到动态构建的 PB 库。因此,您需要添加此预处理器定义。如果可以的话,您也可以静态构建 PB。

您可能还想注意 this :

Note for cross-compiling

The makefiles normally invoke the protoc executable that they just built in order to build tests. When cross-compiling, the protoc executable may not be executable on the host machine. In this case, you must build a copy of protoc for the host machine first, then use the --with-protoc option to tell configure to use it instead. For example:

./configure --with-protoc=protoc

This will use the installed protoc (found in your $PATH) instead of trying to execute the one built during the build process. You can also use an executable that hasn't been installed. For example, if you built the protobuf package for your host machine in ../host, you might do:

./configure --with-protoc=../host/src/protoc

Either way, you must make sure that the protoc executable you use has the same version as the protobuf source code you are trying to use it with.

关于c++ - 交叉编译Qt to Raspberry Pi 3B+ addressbook (Protocol Buffer) - error symbol lookup error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58680056/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com