Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build errors when cross compiling #273

Open
v-lopez opened this issue Jul 26, 2022 · 1 comment
Open

Build errors when cross compiling #273

v-lopez opened this issue Jul 26, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@v-lopez
Copy link

v-lopez commented Jul 26, 2022

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:

  1. 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/

  1. 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/

  1. 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 (7e6b149)

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 #249 (comment) and I get to the same blocking point.

@v-lopez v-lopez added the bug Something isn't working label Jul 26, 2022
@v-lopez
Copy link
Author

v-lopez commented Jul 26, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants