学习记录-交叉编译环境的设置

xilinx交叉编译环境的设置(参考)

# Check for LD_LIBRARY_PATH being set, which can break SDK and generally is a bad practice
# http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80
# http://xahlee.info/UnixResource_dir/_/ldpath.html
# Only disable this check if you are absolutely know what you are doing!
if [ ! -z "$LD_LIBRARY_PATH" ]; then
    echo "Your environment is misconfigured, you probably need to 'unset LD_LIBRARY_PATH'"
    echo "but please check why this was set in the first place and that it's safe to unset."
    echo "The SDK will not operate correctly in most cases when LD_LIBRARY_PATH is set."
    echo "For more references see:"
    echo "  http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80"
    echo "  http://xahlee.info/UnixResource_dir/_/ldpath.html"
    return 1
fi
export SDKTARGETSYSROOT=/opt/petalinux/2021.1/sysroots/cortexa72-cortexa53-xilinx-linux
export PATH=/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/usr/bin:/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/usr/sbin:/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/bin:/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/sbin:/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/usr/bin/../x86_64-petalinux-linux/bin:/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/usr/bin/aarch64-xilinx-linux:/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/usr/bin/aarch64-xilinx-linux-musl:$PATH
export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT
export PKG_CONFIG_PATH=$SDKTARGETSYSROOT/usr/lib/pkgconfig:$SDKTARGETSYSROOT/usr/share/pkgconfig
export CONFIG_SITE=/opt/petalinux/2021.1/site-config-cortexa72-cortexa53-xilinx-linux
export OECORE_NATIVE_SYSROOT="/opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux"
export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT"
export OECORE_ACLOCAL_OPTS="-I /opt/petalinux/2021.1/sysroots/x86_64-petalinux-linux/usr/share/aclocal"
export OECORE_BASELIB="lib"
export OECORE_TARGET_ARCH="aarch64"
export OECORE_TARGET_OS="linux"
unset command_not_found_handle
export CC="aarch64-xilinx-linux-gcc  -mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
export CXX="aarch64-xilinx-linux-g++  -mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
export CPP="aarch64-xilinx-linux-gcc -E  -mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=$SDKTARGETSYSROOT"
export AS="aarch64-xilinx-linux-as "
export LD="aarch64-xilinx-linux-ld  --sysroot=$SDKTARGETSYSROOT"
export GDB=aarch64-xilinx-linux-gdb
export STRIP=aarch64-xilinx-linux-strip
export RANLIB=aarch64-xilinx-linux-ranlib
export OBJCOPY=aarch64-xilinx-linux-objcopy
export OBJDUMP=aarch64-xilinx-linux-objdump
export READELF=aarch64-xilinx-linux-readelf
export AR=aarch64-xilinx-linux-ar
export NM=aarch64-xilinx-linux-nm
export M4=m4
export TARGET_PREFIX=aarch64-xilinx-linux-
export CONFIGURE_FLAGS="--target=aarch64-xilinx-linux --host=aarch64-xilinx-linux --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT"
export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now"
export CPPFLAGS=""
export KCFLAGS="--sysroot=$SDKTARGETSYSROOT"
export OECORE_DISTRO_VERSION="2021.1"
export OECORE_SDK_VERSION="2021.1"
export ARCH=arm64
export CROSS_COMPILE=aarch64-xilinx-linux-

# Append environment subscripts
if [ -d "$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then
    for envfile in $OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do
            . $envfile
    done
fi
if [ -d "$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then
    for envfile in $OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do
            . $envfile
    done
fi

如何根据需要设置自己的交叉编译环境

你可能感兴趣的:(bash,linux,开发语言)