Search code examples
carmx264

Error in compiling x264 on ARM 64-bit platform


The same x264 source code I compiled on Debian 10 (Buster) system has no problem, but I can't compile it on an ARM 64-bit platform. Why?

Maybe there is something wrong with the Makefile, but I don't know where it is.

  1. Configure

    ./configure --disable-asm --enable-shared  --host=aarch64-linux
    
    platform:      AARCH64
    byte order:    little-endian
    system:        LINUX
    cli:           yes
    libx264:       internal
    shared:        yes
    static:        no
    asm:           no
    interlaced:    yes
    avs:           avxsynth
    lavf:          no
    ffms:          no
    mp4:           no
    gpl:           yes
    thread:        posix
    opencl:        yes
    filters:       crop select_every
    lto:           no
    debug:         no
    gprof:         no
    strip:         no
    PIC:           yes
    bit depth:     all
    chroma format: all
    
  2. Edit file config.mak,

    SRCPATH=.
    prefix=/usr/local
    exec_prefix=${prefix}
    bindir=${exec_prefix}/bin
    libdir=${exec_prefix}/lib
    includedir=${prefix}/include
    SYS_ARCH=AARCH64
    SYS=LINUX
    CC=aarch64-linux-gnu-gcc
    CFLAGS=-Wno-maybe-uninitialized -Wshadow -O3 -ffast-math  -Wall -I. -I$(SRCPATH) -std=gnu99 -
    D_GNU_SOURCE -fPIC -fomit-frame-pointer -fno-tree-vectorize
    COMPILER=GNU
    COMPILER_STYLE=GNU
    DEPMM=-MM -g0
    DEPMT=-MT
    LD=aarch64-linux-gnu-gcc -o
    LDFLAGS= -lm -lpthread -ldl
    LIBX264=libx264.a
    AR=aarch64-linux-gnu-gcc-ar rc
    RANLIB=aarch64-linux-gnu-gcc-ranlib
    STRIP=aarch64-linux-gnu-strip
    INSTALL=install
    AS=
    ASFLAGS= -I. -I$(SRCPATH) -DSTACK_ALIGNMENT=16 -DPIC
    RC=
    RCFLAGS=
    EXE=
    HAVE_GETOPT_LONG=1
    DEVNULL=/dev/null
    PROF_GEN_CC=-fprofile-generate
    PROF_GEN_LD=-fprofile-generate
    PROF_USE_CC=-fprofile-use
    PROF_USE_LD=-fprofile-use
    HAVE_OPENCL=yes
    CC_O=-o $@
    default: cli
    install: install-cli
    SOSUFFIX=so
    SONAME=libx264.so.157
    SOFLAGS=-shared -Wl,-soname,$(SONAME)  -Wl,-Bsymbolic
    default: lib-shared
    install: install-lib-shared
    LDFLAGSCLI = -ldl
    CLI_LIBX264 = $(LIBX264)
    
  3. Make, an error occurred, details in error.

  4. Add file config.h after configure,

     #define HAVE_MALLOC_H 1
     #define ARCH_X86_64 1
     #define SYS_LINUX 1
     #define STACK_ALIGNMENT 64
     #define HAVE_POSIXTHREAD 1
     #define HAVE_CPU_COUNT 1
     #define HAVE_THREAD 1
     #define HAVE_LOG2F 1
     #define HAVE_STRTOK_R 1
     #define HAVE_CLOCK_GETTIME 1
     #define HAVE_MMAP 1
     #define HAVE_THP 1
     #define HAVE_AVS 1
     #define USE_AVXSYNTH 1
     #define HAVE_VECTOREXT 1
     #define fseek fseeko
     #define ftell ftello
     #define HAVE_BITDEPTH8 1
     #define HAVE_BITDEPTH10 1
     #define HAVE_GPL 1
     #define HAVE_INTERLACED 1
     #define HAVE_OPENCL (BIT_DEPTH==8)
     #define HAVE_ALTIVEC 0
     #define HAVE_ALTIVEC_H 0
     #define HAVE_MMX 0
     #define HAVE_ARMV6 0
     #define HAVE_ARMV6T2 0
     #define HAVE_NEON 0
     #define HAVE_BEOSTHREAD 0
     #define HAVE_WIN32THREAD 0
     #define HAVE_SWSCALE 0
     #define HAVE_LAVF 0
     #define HAVE_FFMS 0
     #define HAVE_GPAC 0
     #define HAVE_LSMASH 0
     #define HAVE_X86_INLINE_ASM 0
     #define HAVE_AS_FUNC 0
     #define HAVE_INTEL_DISPATCHER 0
     #define HAVE_MSA 0
     #define HAVE_WINRT 0
     #define HAVE_VSX 0
     #define HAVE_ARM_INLINE_ASM 0
    

Solution

  • I have solved it by running

    ./configure --disable-asm --enable-shared --enable-static
    

    and modifying at the same time

    ASFLAGS= -I. -I$(SRCPATH) -f elf64 -DSTACK_ALIGNMENT=64