libyuv編譯(各平台)

來源:互聯網
上載者:User

最近用到視頻格式轉碼,發現Google的開源庫 libyuv 很好用,所以記錄下編譯過程

直接貼 官網的編譯流程

https://chromium.googlesource.com/libyuv/libyuv/+/master/docs/getting_started.md

不過我得吐槽一下,我特麼就想編譯個libyuv 你特麼非要讓我把chrome項目check 下來是幾個意思。。。。如果沒猜錯 應該是好幾個g Getting Started

How to get and build the libyuv code. Pre-requisites

You'll need to have depot tools installed: https://www.chromium.org/developers/how-tos/install-depot-tools Refer to chromium instructions for each platform for other prerequisites.

說明:依賴工具,Google的這套東西還是比較好用的,首先要安裝depottools 這點不多說,命令列就行,最重要的是在下載完成之後要有

export PATH=`pwd`/depot_tools:"$PATH" 命令使能這個工具 Getting the Code

Create a working directory, enter it, and run:

gclient config https://chromium.googlesource.com/libyuv/libyuvgclient sync

說明:設定與同步代碼,裡面內建指令碼,關於代碼如何同步的就無需關心了。


Then you'll get a .gclient file like:

solutions = [  { "name"        : "libyuv",    "url"         : "https://chromium.googlesource.com/libyuv/libyuv",    "deps_file"   : "DEPS",    "managed"     : True,    "custom_deps" : {    },    "safesync_url": "",  },];

For iOS add ;target_os=['ios']; to your OSX .gclient and run GYP_DEFINES="OS=ios" gclient sync.

Browse the Git reprository: https://chromium.googlesource.com/libyuv/libyuv/+/master Android

For Android add ;target_os=['android']; to your Linux .gclient

solutions = [  { "name"        : "libyuv",    "url"         : "https://chromium.googlesource.com/libyuv/libyuv",    "deps_file"   : "DEPS",    "managed"     : True,    "custom_deps" : {    },    "safesync_url": "",  },];target_os = ["android", "unix"];

Then run:

export GYP_DEFINES="OS=android"gclient sync

Caveat: Theres an error with Google Play services updates. If you get the error “Your version of the Google Play services library is not up to date”, run the following: cd chromium/src ./build/android/play_services/update.py download cd ../..

For Windows the gclient sync must be done from an Administrator command prompt.

The sync will generate native build files for your environment using gyp (Windows: Visual Studio, OSX: XCode, Linux: make). This generation can also be forced manually: gclient runhooks

To get just the source (not buildable): git clone https://chromium.googlesource.com/libyuv/libyuv Building the Library and Unittests Windows

set GYP_DEFINES=target_arch=ia32call python gyp_libyuv -fninja -G msvs_version=2013ninja -j7 -C out\Releaseninja -j7 -C out\Debugset GYP_DEFINES=target_arch=x64call python gyp_libyuv -fninja -G msvs_version=2013ninja -C out\Debug_x64ninja -C out\Release_x64
Building with clangcl
set GYP_DEFINES=clang=1 target_arch=ia32 libyuv_enable_svn=1set LLVM_REPO_URL=svn://svn.chromium.org/llvm-projectcall python tools\clang\scripts\update.pycall python gyp_libyuv -fninja libyuv_test.gypninja -C out\Debugninja -C out\Release
OSX

Clang 64 bit shown. Remove clang=1 for GCC and change x64 to ia32 for 32 bit.

GYP_DEFINES="clang=1 target_arch=x64" ./gyp_libyuvninja -j7 -C out/Debugninja -j7 -C out/ReleaseGYP_DEFINES="clang=1 target_arch=ia32" ./gyp_libyuvninja -j7 -C out/Debugninja -j7 -C out/Release
iOS

http://www.chromium.org/developers/how-tos/build-instructions-ios

Add to .gclient last line: target_os=['ios'];

armv7

GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=arm32" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuvninja -j7 -C out_ios/Debug-iphoneos libyuv_unittestninja -j7 -C out_ios/Release-iphoneos libyuv_unittest

arm64

GYP_DEFINES="OS=ios target_arch=arm64 target_subarch=arm64" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuvninja -j7 -C out_ios/Debug-iphoneos libyuv_unittestninja -j7 -C out_ios/Release-iphoneos libyuv_unittest

both armv7 and arm64 (fat)

GYP_DEFINES="OS=ios target_arch=armv7 target_subarch=both" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_ios" ./gyp_libyuvninja -j7 -C out_ios/Debug-iphoneos libyuv_unittestninja -j7 -C out_ios/Release-iphoneos libyuv_unittest

simulator

GYP_DEFINES="OS=ios target_arch=ia32 target_subarch=arm32" GYP_CROSSCOMPILE=1 GYP_GENERATOR_FLAGS="output_dir=out_sim" ./gyp_libyuvninja -j7 -C out_sim/Debug-iphonesimulator libyuv_unittestninja -j7 -C out_sim/Release-iphonesimulator libyuv_unittest
Android

https://code.google.com/p/chromium/wiki/AndroidBuildInstructions

Add to .gclient last line: target_os=['android'];

armv7

GYP_DEFINES="OS=android" GYP_CROSSCOMPILE=1 ./gyp_libyuvninja -j7 -C out/Debug libyuv_unittest_apkninja -j7 -C out/Release libyuv_unittest_apk

arm64

GYP_DEFINES="OS=android target_arch=arm64 target_subarch=arm64" GYP_CROSSCOMPILE=1 ./gyp_libyuvninja -j7 -C out/Debug libyuv_unittest_apkninja -j7 -C out/Release libyuv_unittest_apk

ia32

GYP_DEFINES="OS=android target_arch=ia32" GYP_CROSSCOMPILE=1 ./gyp_libyuvninja -j7 -C out/Debug libyuv_unittest_apkninja -j7 -C out/Release libyuv_unittest_apkGYP_DEFINES="OS=android target_arch=ia32 android_full_debug=1" GYP_CROSSCOMPILE=1 ./gyp_libyuvninja -j7 -C out/Debug libyuv_unittest_apk

mipsel

GYP_DEFINES="OS=android target_arch=mipsel" GYP_CROSSCOMPILE=1 ./gyp_libyuvninja -j7 -C out/Debug libyuv_unittest_apkninja -j7 -C out/Release libyuv_unittest_apk

arm32 disassembly:

third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump -d out/Release/obj/source/libyuv.row_neon.o

arm64 disassembly:

third_party/android_tools/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d out/Release/obj/source/libyuv.row_neon64.o

Running tests:

util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=*

Running test as benchmark:

util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1"

Running test with C code:

util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1"
Building with GN
gn gen out/Release "--args=is_debug=false target_cpu=\"x86\""gn gen out/Debug "--args=is_debug=true target_cpu=\"x86\""ninja -C out/Releaseninja -C out/Debug
Building Offical with GN
gn gen out/Official "--args=is_debug=false is_official_build=true is_chrome_branded=true"ninja -C out/Official
Linux
GYP_DEFINES="target_arch=x64" ./gyp_libyuvninja -j7 -C out/Debugninja -j7 -C out/ReleaseGYP_DEFINES="target_arch=ia32" ./gyp_libyuvninja -j7 -C out/Debugninja -j7 -C out/Release
CentOS

On CentOS 32 bit the following work around allows a sync:

export GYP_DEFINES="host_arch=ia32"gclient sync
Windows Shared Library

Modify libyuv.gyp from ‘static_library’ to ‘shared_library’, and add ‘LIBYUV_BUILDING_SHARED_LIBRARY’ to ‘defines’.

gclient runhooks

After this command follow the building the library instructions above.

If you get a compile error for atlthunk.lib on Windows, read http://www.chromium.org/developers/how-tos/build-instructions-windows Build targets

ninja -C out/Debug libyuvninja -C out/Debug libyuv_unittestninja -C out/Debug compareninja -C out/Debug convertninja -C out/Debug psnrninja -C out/Debug cpuid
Building the Library with make Linux
make -j7 V=1 -f linux.mkmake -j7 V=1 -f linux.mk cleanmake -j7 V=1 -f linux.mk CXX=clang++
Building the Library with cmake

Install cmake: http://www.cmake.org/

Default debug build:

mkdir outcd outcmake ..cmake --build .

Release build/install

mkdir outcd outcmake -DCMAKE_INSTALL_PREFIX="/usr/lib" -DCMAKE_BUILD_TYPE="Release" ..cmake --build . --config Releasesudo cmake --build . --target install --config Release
Windows 8 Phone

Pre-requisite: Install Visual Studio 2012 and Arm to your environment.

Then:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.