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

doc: add crosscompile_with_multiarch #24629

Merged
merged 9 commits into from
Dec 11, 2023

Conversation

Kumataro
Copy link
Contributor

@Kumataro Kumataro commented Dec 1, 2023

Add cross compile tutorial for ubuntu/debian.
( I'm sorry to my poor English. )

Fix #24628

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov asmorkalov self-requested a review December 1, 2023 10:50
@asmorkalov asmorkalov added this to the 4.9.0 milestone Dec 1, 2023
Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great! Very useful tutorial. Also it'll be very useful, if you mention Jetson or Raspbery Pi and how to select proper host system for cross build. jetson OS is based on Ubuntu and Pi os is Debian based.


cmake --build build4-full_armhf
sudo cmake --install build4-full_armhf
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the last step please describe execution on cross-compilation target: you need to install the same versions of 3rdparty packages, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, I will note section tomorrow, thank you very much !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I separate (a) install external libraries, and (b) install opencv which is cross-compile. And I added warning comment that libraries version between compiling and running should be same. Thank you !!

```
[Host]
$ sudo dpkg --add-architecture arm64
$ sudo dpkg --add-architecture armhf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a mix of terminal snippets - starting with $ and without. Prefer avoid $ as documentation does not support copy-to-clipboard option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was worried about how to distinguish between lines input by the user and lines output by the program. So I added a $ sign to the beginning of each line.

However, it becomes a problem when copying and pasting. These have been removed.

[Host] and [Target] to indicate the execution environment also seem to get in the way... I think I'll remove this tomorrow too. Thank you !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I fixed them. In recent document I think it is suitable to copy and paste ! Thank you for your point!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this?

Step3) Update dpkg setting

Update dpkg settings to support foreign architectures.

Execute dpkg --add-architecture with a target architecture:

sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf

And the following comand shows what foreign architectures are supported.

sudo dpkg --print-architecture
arm64
armhf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I split bach script and its result, thank you for your suggestion.

(It was also used for ldd command to detect dependency section.)

@Kumataro
Copy link
Contributor Author

Kumataro commented Dec 2, 2023

Most of the renovations have been completed, but the remaining parts will take a little more time. This is an interim report.

  1. Executing cross compiling with FFmpeg libraries is succeeded.

  2. Enabling python binding is failed.

  • I wanted to use the python3-numpy package provided by apt package manager(same as x86-64 host).
  • But python3-numpy:arm64 requires python3-minimum:arm64.
  • It seems to conflict with python3-minimum:amd64 on host.

Maybe, numpy should be installed with pip.

@Kumataro
Copy link
Contributor Author

Kumataro commented Dec 3, 2023

I believe that I have been fixed all points and applied suggestions.

Thank you very much !!

I believe this tutorial is very helpful to challenge cross-compile.

@Kumataro
Copy link
Contributor Author

Kumataro commented Dec 4, 2023

- Installing runtime packages instead of dev packages in target.
- Add warning for apt package naming.
- Add command to confirm python3 wrapper.
Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! 👍

@asmorkalov asmorkalov self-assigned this Dec 11, 2023
@asmorkalov asmorkalov merged commit b6b40a8 into opencv:4.x Dec 11, 2023
25 of 26 checks passed
@Kumataro
Copy link
Contributor Author

Thank you very much for fixing many problems that I missed !!


@code{.bash}
sudo apt install -y \
python3-dev \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not python3-minimal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment, it is same as "Install OpenCV-Python in Ubuntu".

https://docs.opencv.org/4.x/d2/de6/tutorial_py_setup_in_ubuntu.html

to support python3:
sudo apt-get install python3-dev python3-numpy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python3-dev might conflict with libpython3-dev:aarch64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I created new issue #24695 to commit fix. Thank you !!

@asmorkalov asmorkalov mentioned this pull request Jan 19, 2024
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
…ultiarch

doc: add crosscompile_with_multiarch opencv#24629

Add cross compile tutorial for ubuntu/debian.
( I'm sorry to my poor English. )

Fix opencv#24628

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add crosscompile tutorial with ubuntu/debian
4 participants