MAVSDK icon indicating copy to clipboard operation
MAVSDK copied to clipboard

Building MAVSDK for Android failing (Apple Silicon M2 Max)

Open rayw-dronesense opened this issue 1 year ago • 8 comments

Environment

  • Apple M2 Max Macbook Pro

  • 64 GB RAM

  • Mac OS Ventura

  • Docker Desktop 4.28.0

Problem

I cloned the MAVSDK repo on the main branch, and tried to run the configuration step following the documentation to use dockcross.

However, it fails every single time when it tries to build OpenSSL,

-- extracting...
     src='/work/build/default/third_party/openssl/openssl/src/openssl-3.0.9.tar.gz'
     dst='/work/build/default/third_party/openssl/openssl/src/openssl'
-- extracting... [tar xfz]
-- extracting... [analysis]
-- extracting... [rename]
-- extracting... [clean up]
-- extracting... done
[ 37%] No update step for 'openssl'
[ 50%] Performing patch step for 'openssl'
patching file Configurations/15-android.conf
Hunk #1 succeeded at 130 (offset 18 lines).
[ 62%] Performing configure step for 'openssl'
Configuring OpenSSL version 3.0.9 for target android-arm64
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
Created include/openssl/configuration.h

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL.md file first)      ***
***                                                                ***
**********************************************************************
[ 75%] Performing build step for 'openssl'
make[3]: *** write jobserver: Bad file descriptor.  Stop.
make[3]: *** Waiting for unfinished jobs....
make[3]: *** write jobserver: Bad file descriptor.  Stop.
gmake[2]: *** [CMakeFiles/openssl.dir/build.make:86: openssl/src/openssl-stamp/openssl-build] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/openssl.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
CMake Error at third_party/cmake/build_target.cmake:51 (message):
  /work/build/default/third_party/openssl failed to build!
Call Stack (most recent call first):
  third_party/CMakeLists.txt:23 (build_target)


-- Configuring incomplete, errors occurred!

The command being used to configure the build is

~/dockcross-android-arm64 cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild/default -DBUILD_MAVSDK_SERVER=ON -DBUILD_SHARED_LIBS=ON -H.

The end goal is to make modifications to MAVSDK C++ and bring it into the Android projects (mavsdk_server.aar and mavsdk-java.jar)

rayw-dronesense avatar Mar 13 '24 20:03 rayw-dronesense

It is interesting that the build happening inside a docker container fails on the M2 :thinking:.

Do you know why that would be? What is this "Bad file descriptor"?

JonasVautherin avatar Mar 13 '24 21:03 JonasVautherin

The end goal is to make modifications to MAVSDK C++ and bring it into the Android projects (mavsdk_server.aar and mavsdk-java.jar)

What is the difference between these two? I hope I can further understand and learn.

Jai-GAY avatar Mar 14 '24 01:03 Jai-GAY

It is interesting that the build happening inside a docker container fails on the M2 🤔.

Do you know why that would be? What is this "Bad file descriptor"?

I have no idea. Hence, reaching out to the experts for help 😁

rayw-dronesense avatar Mar 14 '24 13:03 rayw-dronesense

What is the difference between these two? I hope I can further understand and learn.

@Jai-GAY

MAVSDK-Java is a wrapper interface that talks to the 'MAVSDK-server' using generated protobuf interfaces. The 'Server' contains a pre-built .so binary of MAVSDK C++, in this case, targets Android.

Just having the Java wrapper and Server isn't enough, if you are looking to make modifications because the meat underneath is actually within the MAVSDK C++ project.

rayw-dronesense avatar Mar 14 '24 13:03 rayw-dronesense

It seems like openssl fails to build with dockcross on the M2. I would try to remove MAVSDK from the equation and just build OpenSSL first. Then see if that fails or not, and go from there.

This is where we build openssl, you could start from there.

JonasVautherin avatar Mar 14 '24 17:03 JonasVautherin

if you are looking to make modifications because the meat underneath is actually within the MAVSDK C++ project.

okay, so as an open-source spirit, isn't it a pull request, submit?

Jai-GAY avatar Mar 15 '24 01:03 Jai-GAY

FYI: https://github.com/openssl/openssl/issues/23845

julianoes avatar Apr 11 '24 09:04 julianoes

@rayw-dronesense are you still looking into this?

julianoes avatar Apr 11 '24 09:04 julianoes

OP disappeared, not sure what I should do, closing.

julianoes avatar May 27 '24 05:05 julianoes