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

How to compile with Cygwin64 #98

Open
lars18th opened this issue Nov 20, 2022 · 15 comments
Open

How to compile with Cygwin64 #98

lars18th opened this issue Nov 20, 2022 · 15 comments

Comments

@lars18th
Copy link

Hi,

I want to compile this project using Cygwin64. The reason is to obtain binaries based on Linux sources in Windows. I know that the Windows versions are included in the package. But the code is different, so I really need to have a Windows binary linked to cygwin1.dll

So, I've found some troubles, compiling it and I request your help:

  1. The missing go compiler in the Cygwin environment. Because this compiler is missing in the packages, I've installed the Windows version. It's accessible to the Cygwin shell and also to WSL (I want to check first compiling in WSL with the Go windows version). Here the command to configure the CMake with Go for windows:
    • WSL: cmake -DGO_EXECUTABLE=/mnt/e/Go/bin/go.exe ..
    • Cygwin64: cmake -DGO_EXECUTABLE=/cygdrive/E/Go/bin/go.exe ..
  2. This pass all the configuration phase when the needed libraries and tools are installed. However, when compiling in WSL I see this error: go: RLock \\wsl$\Ubuntu\home\dani\dev\android-tools\android-tools-33.0.3p1\vendor\boringssl\go.mod: Incorrect function.
    So I suspect that when the compiling will arrive to this point in the Cygwin64 environment the same error will appears. Any idea to fix this problem? Or almost how to compile with an external go compiler (missing in Cygwin64). Or how to overcome the compilation of the boringssl that is the only part that requires the Go compiler?
  3. Another problem is the compilation of some code with the Cygwin64 toolchain. For example, I obtain this:
[  1%] Building CXX object vendor/CMakeFiles/liblog.dir/logging/liblog/logprint.cpp.o
/home/user/adb/android-tools-33.0.3p1/vendor/logging/liblog/logprint.cpp: In the function ‘int android_log_addFilterString(AndroidLogFormat*, const char*)’:
/home/user/adb/android-tools-33.0.3p1/vendor/logging/liblog/logprint.cpp:465:27: error: ‘strsep’ was not declared in this scope; did you mean ‘strstr’?
  465 |   while (NULL != (p_ret = strsep(&p_cur, " \t,"))) {
      |                           ^~~~~~
      |                           strstr
make[2]: *** [vendor/CMakeFiles/liblog.dir/build.make:160: vendor/CMakeFiles/liblog.dir/logging/liblog/logprint.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:539: vendor/CMakeFiles/liblog.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Any idea to fix this?

I hope you want to help me to compile this package with Cygwin.
Thank you.

@Biswa96
Copy link
Collaborator

Biswa96 commented Nov 20, 2022

Do you want native Windows executable?

@lars18th
Copy link
Author

Do you want native Windows executable?

Native Windows? NO (for this the stock ADB.EXE from Google exists).
Native using "cygwin1.dll", YES.
It's not the same.

@Biswa96
Copy link
Collaborator

Biswa96 commented Nov 20, 2022

I have compiled this project with mingw toolchain, cygwin is not required.

@lars18th
Copy link
Author

I have compiled this project with mingw toolchain, cygwin is not required.

OK. Please, share the binaries. I'll test them.

@Biswa96
Copy link
Collaborator

Biswa96 commented Nov 20, 2022

I can not provide it right now, maybe tomorrow. I have compiled this project in msys2/mingw toolchain. The android-tools programs depend on some of those shared libraries.

@lars18th
Copy link
Author

OK, I'll wait until you provide them. Perhaps if you want then could share as release in your android-tools fork.
Anyway, perhaps it will be interesting to provide a guide to compile with a msys2/mingw toolchain.

Thank you bro!

@anatol
Copy link
Collaborator

anatol commented Nov 20, 2022

@Biswa96 is there any chance you could provide the patches and build instructions required for the mingw/windows port?

@lars18th
Copy link
Author

Hi @Biswa96 ,

Any way, I feel it will be interesting to complete the compilation using the external go compiler. This will help to compile the full package (in fact only the boringssl package that is the only module that requires a go compiler) for other platforms that perhaps will not have accessible this compiler and can be compiled cross-compiling.

You agree?

@Biswa96
Copy link
Collaborator

Biswa96 commented Nov 21, 2022

I did not understand what you are asking. msys2/mingw repository provides all the dependencies and tools we need for adb and fastboot.

@lars18th
Copy link
Author

Hi @Biswa96 ,

I'm testing the binaries. After getting all correct .DLLs (from different mingw-w64-ucrt-x86_64-* packages) the ADB.EXE tool seems to work. However, I need to change some part to fix a bug. In order to compile your binaries: Do you have any docker image for it?

Thank you.

@Biswa96
Copy link
Collaborator

Biswa96 commented Jun 19, 2023

The Windows port of android-tools package is now available in msys2 pacman repository. See https://packages.msys2.org/base/mingw-w64-android-tools

Some patches are added on top of this repository for the Windows port. Those patches can be added here. One of main blocker is the https://android.googlesource.com/platform/development.git repository. Only a fraction of that repository is used for Windows port. Should it be added as git submodule or as any other means? Here is that repo size.

$ du -d 0 -h development/
212M    development/  <--- not required entirely

$ du -d 0 -h development/host/windows/usb/
426K    development/host/windows/usb/  <--- requires only this

@lars18th
Copy link
Author

Hi @Biswa96 ,

A step-by-step how to description of how to compile the package with msys2 will be desirable. I want to fully compile "android-tools" from scratch for Windows MSYS2 target. And I've no idea. What I need is to modify something in the source code of the adb tool. Please could do you help?

Thank you.

@Biswa96
Copy link
Collaborator

Biswa96 commented Jun 22, 2023

A step-by-step how to description of how to compile the package with msys2 will be desirable.

That discussion would be huge and off-topic here. You have to be familiar with pacman packages and read most of the pages in https://wiki.archlinux.org/ and https://www.msys2.org/

@lars18th
Copy link
Author

Hi @Biswa96 ,

The information that I'm searching it's already writed by you: msys2/MINGW-packages#17531

Thanl you! 👍

@lars18th
Copy link
Author

Hi,

To anyone that need this information, here a simple how to compile android-tools for Windows:

  • Install MSYS2

  • Open shell MSYS2 MINGW32 (important because target is Windows32)

  • Install updates/dependencies:
    $ pacman -Suy

    $ pacman -S mingw-w64-i686-android-tools (the package to compile)

    $ pacman -S base-devel git wget
    $ pacman -S mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-go mingw-w64-i686-gtest mingw-w64-i686-nasm mingw-w64-i686-ninja

  • Checkout packages repo: (https://packages.msys2.org/base/mingw-w64-android-tools)
    $ mkdir ~/repos
    $ cd ~/repos
    $ git clone https://github.com/msys2/MINGW-packages.git

  • Compile from source:
    $ cd ~/repos/MINGW-packages/mingw-w64-android-tools
    $ makepkg-mingw --noarchive

  • Get de binaries
    $ cd src/build-MINGW32/vendor
    $ ./adb.exe --version

Note: These binaries are not statically linked. Therefore they can only run inside the MSYS2 environment.

I hope this helps.
Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants