Reputation: 1
cross compile question
Host: ubuntu20.04 x86_64
target: ubuntu20.04 aarch64
toolchain: gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu
sysroot: sysroot-glibc-linaro-2.25-2019.12-aarch64-linux-gnu
when I type the command, cmake output the following error information:
$ colcon build --packages-select cv_bridge --build-base crossbuild --install crossinstall --cmake-args -DCMAKE_TOOLCHAIN_FILE=/path/to/aarch64-linux-gnu.cmake
Starting >>> cv_bridge
--- stderr: cv_bridge
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Python3 (missing: Python3_LIBRARIES Python3_INCLUDE_DIRS
Python3_NumPy_INCLUDE_DIRS Development NumPy) (found version "3.8.10")
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.16/Modules/FindPython/Support.cmake:2214 (find_package_handle_standard_args)
/usr/share/cmake-3.16/Modules/FindPython3.cmake:300 (include)
CMakeLists.txt:21 (find_package)
---
Failed <<< cv_bridge [1.98s, exited with code 1]
the key words are that "missing: Python3_LIBRARIES Python3_INCLUDE_DIRS Python3_NumPy_INCLUDE_DIRS Development NumPy"
But throw the error:
Could NOT find Python3 (missing: Python3_NumPy_INCLUDE_DIRS NumPy) (found
version "3.8.10")
As a noob in CMake, what I can understand is that I have tried is the lack of the numpy library, so I tried to install numpy using crossenv and pip. However, there were too many errors reported, so I gave up on this approach.
Moreover, I also tried copying the numpy* files from the python/site-packages directory on the aarch64 architecture to the cross-compiled python/site-packages directory, but it still didn't solve the problem. I guess even if I manage to install numpy using this method, the final installation location would not be related to the cross-compiled python.
I am hoping someone can answer this question, and I am extremely grateful.
Upvotes: 0
Views: 2086
Reputation: 537
I assume you are using virtualenv or conda environment for cross-compiling, so you have to be more specific about what python
binary to use:
colcon build --symlink-install --cmake-args -DPython3_FIND_VIRTUALENV=ONLY
Or you can directly specify what version you want to use for your colcon
build:
colcon build --symlink-install \
-DPython3_EXECUTABLE:INTERNAL=$CONDA_PREFIX/bin/python3 \
-DPython3_FIND_STRATEGY=LOCATION -DPython3_FIND_UNVERSIONED_NAMES=FIRST
All other flags are here: https://cmake.org/cmake/help/latest/module/FindPython3.html.
I also assume you have installed numpy
in that python env.
Pro tip: you can save these flags in your colcon.pkg file.
Upvotes: 1