移植hdf5到hi3519

来源:互联网 发布:执信软件 编辑:程序博客网 时间:2024/06/07 03:24

1.编译环境

  • Ubuntu16.4 + arm-hisiv500-linux-
  • 下载地址:https://support.hdfgroup.org/HDF5/release/obtain518.html

2.移植步骤

  • cmake配置:cmake-gui

选择源码路径,编译配置文件路径,编译器,点击configure(其会报错,不用管,再次点击即可),选择安装路径,点击generate

  • 参考如下脚本来安装:

    • 1)更改一下交叉编译工具
    • 2)如果ssh工具没有,可以使用telnet,该库的移植需要在宿主机编译,在目标机执行一些初始化的程序,生成一些arm平台的配置文件,然后在继续编译
#!/bin/sh# to cross compile the hdf5 library on arm we need some generated source code# from the target platform.# This script does the following:# 1. setup a cmake build# 2. try to build with pre generated files (you have to generate them)#    Place them in arm_files/generated/${platform}#    (relative to the directory you start this script) eg:##    arm_files/generated/#    ├── sam9#    │   ├── H5lib_settings.c#    │   └── H5Tinit.c#    └── xilinx#        ├── H5lib_settings.c#        └── H5Tinit.c#   # 2. OR connect via ssh with this script to your arm target and it will#    generate the files on the fly## preconditions:# -------------# - we need cmake# - we need a cross compiler reachable within $PATH so cmake can detect# - download source code: hdf5-1.8.16.tar.bz2# - extract tarball# - go into extracted tarball and start this script#   eg ./build_hdf5.sh generate#   OR if you have pregenerated files for H5lib_settings.c and H5Tinit.c#   ./build_hdf5.sh##########################################################g_generate_on_host="192.168.0.6"g_generate="$1"G_GENERATE_H5DETECT="H5Tinit.c"G_GENERATE_H5MAKE_LIBSETTINGS="H5lib_settings.c"G_INITIAL_DIR="$PWD"function cmake_tool_chain_helper(){    local toolchain="$1"    local build_dir="$2"    cat << EOF > $build_dir/${toolchain}.cmake    set(CMAKE_SYSTEM_NAME Linux)    set(CMAKE_SYSTEM_PROCESSOR arm)    set(CMAKE_C_COMPILER    $toolchain-gcc)    set(CMAKE_CXX_COMPILER  $toolchain-g++)    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)EOF}function generate_fake_tools(){    echo "#!/bin/sh" > H5detect    echo "#!/bin/sh" > H5make_libsettings    chmod +x H5detect H5make_libsettings}function build_for_platform(){    local platform="$1"    local build_dir="$2"    local toolchain="$3"    local install_dir="$4"    test -e "$build_dir" || mkdir -p "$build_dir"    cd "$build_dir"    cmake_tool_chain_helper "$toolchain" "$build_dir"    # run 2 times as errors will occur due to not supported cross compiling    # 1st run configure    # 2nd run generate Makefiles    for x in 1 2 ; do        cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="${build_dir}/${toolchain}.cmake" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${install_dir}" \            -DBUILD_TESTING=false -DHDF5_BUILD_EXAMPLES=false -DCMAKE_CXX_FLAGS="-D_GNU_SOURCE" -DCMAKE_C_FLAGS="-D_GNU_SOURCE" ..    done    # make: it will fail several time due to plattform depending files to be generated    # we have them allready generated on the arm platform    # so we replace the tools with a fake tools    local path_gen_files="${G_INITIAL_DIR}/arm_files/generated/${platform}"    if [ "$g_generate" == "generate" ] ;then        local dir=/path/on/device/        path_gen_files="/tmp/h5_generated"        test -e "$path_gen_files"  || mkdir "$path_gen_files"        for x in  bin/H5detect bin/H5make_libsettings H5detect H5make_libsettings; do            test -e "$x" && rm "$x"        done        # try to generate files on host -> this will fail        make        echo "-------------------"        echo "# ---> copy files to target"        echo "-------------------"        scp bin/H5detect bin/H5make_libsettings libhdf5.settings root@${g_generate_on_host}:${dir} || exit 1        echo "-------------------"        echo "# ---> chmod those files"        echo "-------------------"        ssh root@${g_generate_on_host} "cd $dir &> /dev/null ; chmod +x H5detect H5make_libsettings"        echo "-------------------"        echo "# ---> generate "$path_gen_files"/$G_GENERATE_H5DETECT"        echo "-------------------"        ssh root@${g_generate_on_host} "cd $dir &> /dev/null ; ./H5detect" > "$path_gen_files"/$G_GENERATE_H5DETECT        echo "-------------------"        echo "# ---> generate "$path_gen_files"/$G_GENERATE_H5MAKE_LIBSETTINGS"        echo "-------------------"        ssh root@${g_generate_on_host} "cd $dir &> /dev/null ; ./H5make_libsettings" > "$path_gen_files"/$G_GENERATE_H5MAKE_LIBSETTINGS    fi    # below steps needs to be done twice as make tries to generate with arm binary on x86 (H5detect)    # and second for H5make_libsettings    make    generate_fake_tools    cp "$path_gen_files"/$G_GENERATE_H5MAKE_LIBSETTINGS .    cp "$path_gen_files"/$G_GENERATE_H5DETECT .    make    generate_fake_tools    cp "$path_gen_files"/$G_GENERATE_H5MAKE_LIBSETTINGS .    cp "$path_gen_files"/$G_GENERATE_H5DETECT .    # no start the real build    make -j4    make install}#build_for_platform "xilinx" "$PWD/build_xilinx" "arm-xilinx-linux-gnueabi" "$PWD/install_xilinx"#build_for_platform "sam9" "$PWD/build_sam9" "arm-none-linux-gnueabi" "$PWD/install_sam9"</code><!--more-->
0 0
原创粉丝点击