一、参考资料
在ubuntu中,交叉编译harfbuzz,freetype,opencv(包括WITH_QT),并移植到linux开发板
二、交叉编译harfbuzz
重要说明:因为harfbuzz和freetype相互依赖,所以要么先编译harfbuzz(不带freetype),然后编译freetype(带harfbuzz),然后编译harfbuzz(带freetype);要么就反过来,先编译freetype。
1. 下载harfbuzz源码
下载harfbuzz:https://github.com/harfbuzz/harfbuzz
下载并解压源码。
tar -xvzf harfbuzz-10.2.0.tar.gz
cd harfbuzz-10.2.0
2. 设置环境变量
设置交叉编译工具链的bin路径:
export PATH=/home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/bin:$PATH
3. cmake 编译(不带freetype)
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX="/home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install" \
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
-DHB_HAVE_FREETYPE=OFF \
-DHB_HAVE_ICU=OFF \
-DHB_HAVE_GLIB=OFF ..
输出示例:
yoyo@ubuntu:~/360Downloads/harfbuzz-10.2.0/build$ cmake -DCMAKE_BUILD_TYPE=Release \
> -DCMAKE_INSTALL_PREFIX="/home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install" \
> -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
> -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
> -DHB_HAVE_FREETYPE=OFF \
> -DHB_HAVE_ICU=OFF \
> -DHB_HAVE_GLIB=OFF ..
-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
WARNHarfBuzz has a Meson port and tries to migrate all the other build systems to it, please consider using it as we might remove our cmake port soon.
-- Found Python3: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter
-- Looking for atexit
-- Looking for atexit - found
-- Looking for mprotect
-- Looking for mprotect - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Looking for getpagesize
-- Looking for getpagesize - found
-- Looking for mmap
-- Looking for mmap - found
-- Looking for isatty
-- Looking for isatty - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/mman.h
-- Looking for sys/mman.h - found
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Performing Test CXX_SUPPORTS_FLAG_BSYMB_FUNCS
-- Performing Test CXX_SUPPORTS_FLAG_BSYMB_FUNCS - Success
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Success
-- Configuring done (1.8s)
-- Generating done (0.0s)
-- Build files have been written to: /home/yoyo/360Downloads/harfbuzz-10.2.0/build
4. cmake 编译(带freetype)
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX="/home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install" \
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
-DCMAKE_FIND_ROOT_PATH=/home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/libc \
-DHB_HAVE_FREETYPE=ON \
-DHB_HAVE_CAIRO=OFF \
-DHB_HAVE_ICU=OFF \
-DHB_HAVE_GLIB=OFF \
-DCMAKE_PREFIX_PATH="/home/yoyo/360Downloads/freetype-2.13.0/arm32_install" \
-DCMAKE_EXE_LINKER_FLAGS="-L/home/yoyo/360Downloads/freetype-2.13.0/arm32_install/lib -lfreetype \
-L/home/yoyo/360Downloads/libpng-1.6.45/arm32_install/lib -lpng \
-L/home/yoyo/360Downloads/zlib-1.3.1/zlibbuild/lib -lz \
-L/home/yoyo/360Downloads/bzip2-1.0.8/arm32_install/lib -lbz2" ..
输出示例:
yoyo@ubuntu:~/360Downloads/harfbuzz-10.2.0/build$ cmake -DCMAKE_BUILD_TYPE=Release \
> -DCMAKE_INSTALL_PREFIX="/home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install" \
> -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
> -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
> -DCMAKE_FIND_ROOT_PATH=/home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/libc \
> -DHB_HAVE_FREETYPE=ON \
> -DHB_HAVE_ICU=OFF \
> -DHB_HAVE_GLIB=OFF \
> -DCMAKE_EXE_LINKER_FLAGS="-L/home/yoyo/360Downloads/freetype-2.13.0/arm32_install/lib -lfreetype \
> -L/home/yoyo/360Downloads/libpng-1.6.45/arm32_install/lib -lpng \
> -L/home/yoyo/360Downloads/zlib-1.3.1/zlibbuild/lib -lz \
> -L/home/yoyo/360Downloads/bzip2-1.0.8/arm32_install/lib -lbz2" ..
-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
WARNHarfBuzz has a Meson port and tries to migrate all the other build systems to it, please consider using it as we might remove our cmake port soon.
-- Found Python3: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter
-- Looking for atexit
-- Looking for atexit - found
-- Looking for mprotect
-- Looking for mprotect - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Looking for getpagesize
-- Looking for getpagesize - found
-- Looking for mmap
-- Looking for mmap - found
-- Looking for isatty
-- Looking for isatty - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/mman.h
-- Looking for sys/mman.h - found
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found Freetype: /home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/libfreetype.so (found version "2.13.0")
-- Looking for FT_Get_Var_Blend_Coordinates
-- Looking for FT_Get_Var_Blend_Coordinates - not found
-- Looking for FT_Set_Var_Blend_Coordinates
-- Looking for FT_Set_Var_Blend_Coordinates - not found
-- Looking for FT_Done_MM_Var
-- Looking for FT_Done_MM_Var - not found
-- Performing Test CXX_SUPPORTS_FLAG_BSYMB_FUNCS
-- Performing Test CXX_SUPPORTS_FLAG_BSYMB_FUNCS - Failed
-- Performing Test COMPILER_SUPPORTS_CXX11
-- Performing Test COMPILER_SUPPORTS_CXX11 - Failed
-- The compiler /home/yoyo/360Downloads/toolchains/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ has no C++11 support. Please use a different C++ compiler.
-- Configuring done (2.0s)
-- Generating done (0.0s)
-- Build files have been written to: /home/yoyo/360Downloads/harfbuzz-10.2.0/build
5. make 编译安装
# 编译
make -j8
# 安装
make install
make
编译:
yoyo@ubuntu:~/360Downloads/harfbuzz-10.2.0/build$ make -j8
[ 5%] Building CXX object CMakeFiles/harfbuzz.dir/src/harfbuzz.cc.o
[ 11%] Linking C static library libharfbuzz.a
[ 11%] Built target harfbuzz
[ 17%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-ot-cff1-table.cc.o
[ 23%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-number.cc.o
[ 29%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-ot-cff2-table.cc.o
[ 35%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-static.cc.o
[ 41%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-cff-common.cc.o
[ 47%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-cff1.cc.o
[ 52%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-input.cc.o
[ 58%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-cff2.cc.o
[ 64%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-instancer-iup.cc.o
[ 70%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-instancer-solver.cc.o
[ 76%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-plan.cc.o
[ 82%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset-serialize.cc.o
[ 88%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/hb-subset.cc.o
[ 94%] Building CXX object CMakeFiles/harfbuzz-subset.dir/src/graph/gsubgpos-context.cc.o
[100%] Linking C static library libharfbuzz-subset.a
[100%] Built target harfbuzz-subset
make install
安装:
yoyo@ubuntu:~/360Downloads/harfbuzz-10.2.0/build$ make install
[ 11%] Built target harfbuzz
[100%] Built target harfbuzz-subset
Install the project...
-- Install configuration: "Release"
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-aat-layout.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-aat.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-blob.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-buffer.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-common.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-cplusplus.hh
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-deprecated.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-draw.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-face.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-font.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-map.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-color.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-deprecated.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-font.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-layout.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-math.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-meta.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-metrics.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-name.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-shape.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot-var.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ot.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-paint.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-set.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-shape-plan.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-shape.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-style.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-unicode.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-version.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-ft.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-subset.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-subset-serialize.h
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/lib/libharfbuzz.a
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/lib/pkgconfig/harfbuzz.pc
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/lib/cmake/harfbuzz/harfbuzzConfig.cmake
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/lib/cmake/harfbuzz/harfbuzzConfig-release.cmake
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/lib/libharfbuzz-subset.a
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/lib/pkgconfig/harfbuzz-subset.pc
-- Installing: /home/yoyo/360Downloads/harfbuzz-10.2.0/arm32_install/include/harfbuzz/hb-features.h
6. 移植到开发板
将编译好的文件,拷贝到开发板。
# 拷贝 include
cp -r ./arm32_install/include/* /PATH/TO/arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include
# 拷贝lib
cp -r ./arm32_install/lib/* /PATH/TO/arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib
技术交流群
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。