背景
本来想着把 x265编译到ffmpeg里面,搞定了x265的编译;但是一直报ERROR: x265 not found using pkg-config
这个错误,我按照网上的资料,查看了ffbuild/config.log
,也修改了 .pc 也export 了,可是还是不行。好像是与数学库有关,但是添加了-lm -stdc++
都无济于事。
先把 x265 交叉编译的成果分享出来,有空再试着搞搞
编译
一个脚本搞定。
##
# Copyright By Schips, All Rights Reserved
# https://gitee.com/schips/
# File Name: make.sh
# Created : Mon 02 Sep 2019 08:05:53 PM HKT
##
#!/bin/sh
BASE=`pwd`
BUILD_HOST=arm-linux
OUTPUT_PATH=${BASE}/install
set_env () {
sudo apt-get install cmake -y
}
make_dirs () {
#为了方便管理,创建有关的目录
cd ${BASE} && mkdir compressed install source -p
}
tget () { #try wget
filename=`basename $1`
echo "Downloading [${filename}]..."
if [ ! -f ${filename} ];then
wget $1
fi
echo "[OK] Downloaded [${filename}] "
}
download_package () {
cd ${BASE}/compressed
tget http://download.videolan.org/videolan/x265/x265_3.0.tar.gz
}
tar_package () {
cd ${BASE}/compressed
ls * > /tmp/list.txt
for TAR in `cat /tmp/list.txt`
do
tar -xf $TAR -C ../source
done
rm -rf /tmp/list.txt
}
make_x265() {
# 其他编译选项可以 通过 在 cmake ../source 以后 ccmake ../source 可以查看 ( ccmake 可以通过 sudo apt-get install cmake-curses-gui 进行安装 )
cd ${BASE}/source/x265*/source
# 获取 工具链所在位置 下面的操作为的是在 CMakeLists.txt 中插入下面内容
#set( CMAKE_SYSTEM_NAME Linux )
#set( CMAKE_SYSTEM_PROCESSOR ARM )
#set( CMAKE_C_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin/arm-hisiv500-linux-gcc" )
#set( CMAKE_CXX_COMPILER "/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin/arm-hisiv500-linux-g++" )
#set( CMAKE_FIND_ROOT_PATH "/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin/" )
GCC_FULL_PATH=`whereis ${BUILD_HOST}-gcc | awk -F: '{ print $2 }' | awk '{print $1}'` # 防止多个结果
GCC_DIR=`dirname ${GCC_FULL_PATH}/`
sed -i "1i\set( CMAKE_SYSTEM_NAME Linux )" CMakeLists.txt
sed -i "2a\set( CMAKE_SYSTEM_PROCESSOR ARM )" CMakeLists.txt
sed -i "2a\set( CMAKE_C_COMPILER ${GCC_DIR}/${BUILD_HOST}-gcc )" CMakeLists.txt
sed -i "2a\set( CMAKE_CXX_COMPILER ${GCC_DIR}/${BUILD_HOST}-g++ )" CMakeLists.txt
sed -i "2a\set( CMAKE_FIND_ROOT_PATH ${GCC_DIR} )" CMakeLists.txt
cmake ../source
# 指定安装路径
sed -i "1i\set( CMAKE_INSTALL_PREFIX "${BASE}/install/x265" )" cmake_install.cmake
make && make install
}
set_env
make_dirs
download_package
tar_package
make_x265