Compiling Windows version adb based on Ubuntu

Source: Internet
Author: User

.

.

.

.

.

ADB source code in the Android source tree, so can only be compiled under Linux, and Linux under the compilation of Windows version of the application will need to use the cross compiler MinGW.

Environment:

Ubuntu 16.04

Android 4.3 r2

uname -alinux yuhuashi4.4. 2 #2: £ x86_64 x86_64 x86_64 gnu/  linux>$

Compile steps:

1. Install the cross-compiler first. Since the LZ has already been installed, this will prompt you to be the latest version. Some tutorials on the web say to install MINGW32, but LZ from the source to search for the relevant package, so LZ installed is mingw-w64 this package.

sudo Install mingw-w64reading Package lists ... Donebuilding Dependency Tree       Reading State information ... Donemingw-w64 is already the newest version (4.0.  4-2). 0 0 0  $ Not upgraded.

2. Next, without a cross-compiler, we enter the Android source tree directory and configure the target platform for ADB compilation. LZ selected is Aosp_x86-eng, of course, you can also use the Choosecombo command to replace the lunch command for detailed configuration.

>$ CD android/>$ source Build/envsetup.SHincluding device/asus/deb/vendorsetup.SHincluding device/asus/flo/vendorsetup.SHincluding device/asus/grouper/vendorsetup.SHincluding device/asus/tilapia/vendorsetup.SHincluding device/generic/armv7-a-neon/vendorsetup.SHincluding device/generic/mips/vendorsetup.SHincluding device/generic/x86/vendorsetup.SHincluding device/lge/mako/vendorsetup.SHincluding device/samsung/maguro/vendorsetup.SHincluding device/samsung/manta/vendorsetup.SHincluding device/samsung_slsi/arndale/vendorsetup.SHincluding device/samsung/toroplus/vendorsetup.SHincluding device/samsung/toro/vendorsetup.SHincluding device/ti/panda/vendorsetup.SHincluding SDK/bash_completion/Adb.bash>$ lunchyou're Building on LinuxLunch Menu ... pick a combo:1. aosp_arm-Eng2. aosp_x86-Eng3. aosp_mips-Eng4. vbox_x86-Eng5. aosp_deb-Userdebug6. aosp_flo-Userdebug7. full_grouper-Userdebug8. full_tilapia-Userdebug9. mini_armv7a_neon-UserdebugTen. mini_mips-Userdebug One. mini_x86-Userdebug A. full_mako-Userdebug -. full_maguro-Userdebug -. full_manta-Userdebug the. full_arndale-Userdebug -. full_toroplus-Userdebug -. full_toro-Userdebug -. full_panda-Userdebugwhich would? [Aosp_arm-eng]2============================================Platform_version_codename=relplatform_version=4.3target_product=aosp_x86target_build_variant=Engtarget_build_type=Releasetarget_build_apps=Target_arch=x86target_arch_variant=x86target_cpu_variant=Host_arch=X86host_os=Linuxhost_os_extra=linux-4.4.2-x86_64-with-ubuntu-16.04-Xenialhost_build_type=releasebuild_id=Jsr78dout_dir= out============================================>$

2. After the configuration of the compilation environment, the first compilation will need to compile the Linux version of the ADB, or compile the time there will be some libraries can not find, and then compile to skip this step.

>$ Make-J8 adb============================================Platform_version_codename=relplatform_version=4.3target_product=aosp_x86target_build_variant=Engtarget_build_type=Releasetarget_build_apps=Target_arch=x86target_arch_variant=x86target_cpu_variant=Host_arch=X86host_os=Linuxhost_os_extra=linux-4.4.2-x86_64-with-ubuntu-16.04-Xenialhost_build_type=releasebuild_id=Jsr78dout_dir= out============================================# ... Omit n rows ... target executable:adb (out/target/product/generic_x86/obj/executables/adb_intermediates/linked/adb) Target symbolic:adb (out/target/product/generic_x86/symbols/system/bin/adb) Target strip:adb (out/target/product/generic_x86/obj/executables/adb_intermediates/adb) Install:out/target/product/generic_x86/system/bin/adb>$

3. Next, we will configure the relevant path of the cross-compiler we just installed to the build/core/combo/host_windows-x86.mk file of the Android source tree.

Green is commented out is the contents of the original file, red is the LZ modified content.

Your modified content does not have to be the same as the LZ, to see for themselves what the actual path, and then configure according to the actual situation.

This script is simple, why do we only modify the content of else, because in a moment to compile the Windows version of the ADB, we will give make a parameter called Use_mingw.

# Settings to use MinGW have a cross-compiler under LINUXIFNEQ ($ (findstring linux,$ (UNAME)),) Ifneq ($ (Strip $ (USE_MINGW)), host_acp_unavailable: =trueTools_exe_suffix:=Host_global_cflags+= -Duse_mingwifneq ($ (Strip $ (build_host_64bit)), Tools_prefix:=/usr/bin/amd64-mingw32msvc-Host_c_includes+ =/usr/lib/GCC/amd64-mingw32msvc/4.4.2/Includehost_global_ld_dirs+ =-l/usr/amd64-mingw32msvc/LibElse# Tools_prefix: =/usr/bin/i586-mingw32msvc-Tools_prefix: =/usr/bin/i686-w64-mingw32-# Host_c_includes + =/usr/lib/gcc/i586-mingw32msvc/3.4.4/includeHost_c_includes + =/usr/i686-w64-mingw32/ include# host_global_ld_dirs + =-l/usr/i586-mingw32msvc/ Libhost_global_ld_dirs + =-l/usr/i686-w64-mingw32/ Libendif # build_host_64bitendif # use_mingwendif # linuxhost_cc:= $ (Tools_prefix)GCC$ (tools_exe_suffix)# host_cxx: = $ (tools_prefix) g++ $ (tools_exe_suffix)host_cxx: = $ (tools_prefix) g++-static- libgcc$ (tools_exe_suffix)Host_ar:= $ (Tools_prefix)ar$ (Tools_exe_suffix)

4. Next to modify a MinGW inside a header file:/usr/share/mingw-w64/include/wincrypt.h, this path also depends on your own MinGW path, not necessarily the same as the LZ.

The inside Ocsp_request macro location near a large section of macros are commented out, LZ guess may be all the macros are commented out also can, but LZ did not try.

LZ here was the day of the pit, due to MinGW inside some macro and Android source tree under the External/openssl inside some macro name repeated, resulting in the compilation of a variety of strange phenomenon.

This step LZ does not post code, do not forget to compile the Windows version of the ADB, after the/usr/share/mingw-w64/include/wincrypt.h file restore back.

5. After a series of preparations above, we can now finally compile our protagonist.

>$ Make-j8 use_mingw=y adb============================================Platform_version_codename=relplatform_version=4.3target_product=aosp_x86target_build_variant=Engtarget_build_type=Releasetarget_build_apps=Target_arch=x86target_arch_variant=x86target_cpu_variant=Host_arch=X86host_os=Windowshost_os_extra=linux-4.4.2-x86_64-with-ubuntu-16.04-Xenialhost_build_type=releasebuild_id=Jsr78dout_dir= out============================================... Omit n rows ... host Prebuilt:adbwinusbapi (out/host/windows-x86/obj/executables/adbwinusbapi_intermediates/AdbWinUsbApi.dll) Install:out/host/windows-x86/bin/adbwinusbapi.dllhost Prebuilt:adbwinapi (out/host/windows-x86/obj/executables/adbwinapi_intermediates/AdbWinApi.dll) Install:out/host/windows-x86/bin/adbwinapi.dllhost executable:adb (out/host/windows-x86/obj/executables/adb_intermediates/Adb.exe) Install:out/host/windows-x86/bin/Adb.exe>$

If you see the final generation of 3 files: AdbWinUsbApi.dll, AdbWinApi.dll and Adb.exe, then congratulations on your compilation success, quickly put these three files in Windows to try it.

Compiling Windows version adb based on Ubuntu

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.