qtprotobuf
qtprotobuf copied to clipboard
Build errors when cross compiling
Describe the bug Following the steps at https://github.com/semlanik/qtprotobuf#cross-compiling I cannot build the target host version of qtprotobuf.
There are multiple CMake errors:
- QtProtobuf not found
CMake Error at CMakeLists.txt:33 (find_package):
Could not find a package configuration file provided by "QtProtobuf" with
any of the following names:
QtProtobufConfig.cmake
Even though I am providing -DQT_PROTOBUF_HOST_PATH=/usr/local/qtprotobuf-qt5/lib/cmake
.
I can workaround this with -DQtProtobuf_DIR=/usr/local/qtprotobuf-qt5/lib/cmake/QtProtobuf/
- Qt5 not found
CMake Error at CMakeLists.txt:39 (find_package):
Could not find a package configuration file provided by "Qt5" with any of
the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
Even though I am providing -DCMAKE_PREFIX_PATH=/opt/Qt5/5.15.2/android/
I can work around it with -DQt5_DIR=/opt/Qt5/5.15.2/android/lib/cmake/Qt5/
- Qt5Core, Qt5Qml, Qt5Network not found With a similar error to above, also workaroundable via _DIR variable.
And the blocking protoc exec format error for me. This is the one I cannot workaround:
/bin/sh: 1: /home/user/qtprotobuf/build-android-qt5/3rdparty/grpc/third_party/protobuf/protoc-3.14.0.0: Exec format error
It seems like it is using the protoc from the target system (android) instead of the one provided from the host.
To Reproduce Replicate the Cross-Compiling section of the manual. I am using the following cmake command for host:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/qtprotobuf-qt5 -DQT_PROTOBUF_MAKE_TESTS=false -DQT_PROTOBUF_MAKE_EXAMPLES=false
cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local/qtprotobuf-qt5-android -DQT_PROTOBUF_MAKE_TESTS=OFF -DQT_PROTOBUF_MAKE_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE:FILEPATH=/home/user/Android/Sdk/ndk/22.1.7171670/build/cmake/android.toolchain.cmake -DQT_PROTOBUF_HOST_PATH=/usr/local/qtprotobuf-qt5/lib/cmake -DCMAKE_PREFIX_PATH=/opt/Qt5/5.15.2/android/
The additional flags I need to pass to get the protoc error are:
-DQtProtobuf_DIR=//usr/local/qtprotobuf-qt5/lib/cmake/QtProtobuf/ -DQt5_DIR=/opt/Qt5/5.15.2/android/lib/cmake/Qt5/ -DQt5Core_DIR=/opt/Qt5/5.15.2/android/lib/cmake/Qt5Core/ -DQt5Qml_DIR=/opt/Qt5/5.15.2/android/lib/cmake/Qt5Qml/ -DQt5Network_DIR=/opt/Qt5/5.15.2/android/lib/cmake/Qt5Network/
Expected behavior
Environment:
- OS: Ubuntu 20.04
- Version master (7e6b149b47e637d66fa901d49ee6ac696b8e6128)
Additional context I am not sure if it's a typo or is intended (I've tried both). But on the Cross Compiling manual, the build the target QtProtobuf section is executed on the same build dir as the host version
mkdir build-host cd build-host
I am also trying Qt6 with this patch https://github.com/semlanik/qtprotobuf/issues/249#issue-1033814240 and I get to the same blocking point.
It seems this problem (the protoc exec error) only occurs when building the dependencies as submodules.
I can live with that, feel free to close @semlanik if you think cross compilation with dependencies as submodules is out of the scope.