OpenHEVC/openHEVC

OpenHEVC cross-compilation fails on FC18 32-bit machine.

Closed this issue · 5 comments

We are cross compiling OpenHEVC for Windows on a FC18 32-bit system. The command line to compile is as follows:
cmake -DCMAKE_TOOLCHAIN_FILE=/root/openHEVC/Toolchain-mingw32.cmake -DCMAKE_BUILD_TYPE=RELEASE ..

The extract of toolchain file is as follows:

the name of the target operating system

SET(CMAKE_SYSTEM_NAME Windows)

which compilers to use for C and C++

SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)

here is the target environment located

SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32/ )

adjust the default behaviour of the FIND_XXX() commands:

search headers and libraries in the target environment, search

programs in the host environment

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)

set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

The error we get is as follows:

[ 1%] Building C object CMakeFiles/LibOpenHevcWrapper.dir/libavcodec/hevc_cabac.c.obj
/root/openHEVC/openHEVC_win/libavcodec/hevc_cabac.c:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
In file included from /root/openHEVC/openHEVC_win/libavcodec/cabac_functions.h:36:0,
from /root/openHEVC/openHEVC_win/libavcodec/hevc_cabac.c:27:
/root/openHEVC/openHEVC_win/libavcodec/cabac_functions.h: In function 'get_cabac':
/root/openHEVC/openHEVC_win/libavcodec/x86/cabac.h:173:5: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'
/root/openHEVC/openHEVC_win/libavcodec/x86/cabac.h:167:5: error: 'asm' operand has impossible constraints
/root/openHEVC/openHEVC_win/libavcodec/x86/cabac.h:173:5: error: 'asm' operand has impossible constraints
make[2]: *** [CMakeFiles/LibOpenHevcWrapper.dir/libavcodec/hevc_cabac.c.obj] Error 1
make[1]: *** [CMakeFiles/LibOpenHevcWrapper.dir/all] Error 2
make: *** [all] Error 2

The same project compiles fine for Linux platform.

Hi,

My sincere apology as due to some special characters, few lines are seen in bold letters. If needed, I can close this thread and start a new thread again.

Instead of using the openHEVC wrapper, consider using libav directly: https://github.com/OpenHEVC/libav It's build system is much more mature.

We tried to cross-compile libav and got the following error.
cmdline: ./configure --disable-runtime-cpudetect --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --arch=i686

First few lines of the errors:

In file included from libavcodec/x86/hevc_idct_sse4.c:17:0:
/usr/lib/gcc/i686-w64-mingw32/4.7.2/include/emmintrin.h:32:3: error: #error "SSE2 instruction set not enabled"
In file included from libavcodec/x86/hevc_idct_sse4.c:18:0:
/usr/lib/gcc/i686-w64-mingw32/4.7.2/include/tmmintrin.h:31:3: error: #error "SSSE3 instruction set not enabled"
In file included from libavcodec/x86/hevc_idct_sse4.c:19:0:
/usr/lib/gcc/i686-w64-mingw32/4.7.2/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled"
CC libavcodec/x86/hevc_idct_sse4.o
In file included from libavcodec/x86/hevc_idct_sse4.c:17:0:
/usr/lib/gcc/i686-w64-mingw32/4.7.2/include/emmintrin.h:32:3: error: #error "SSE2 instruction set not enabled"
In file included from libavcodec/x86/hevc_idct_sse4.c:18:0:
/usr/lib/gcc/i686-w64-mingw32/4.7.2/include/tmmintrin.h:31:3: error: #error "SSSE3 instruction set not enabled"
In file included from libavcodec/x86/hevc_idct_sse4.c:19:0:
/usr/lib/gcc/i686-w64-mingw32/4.7.2/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled"
libavcodec/x86/hevc_idct_sse4.c: In function 'ff_hevc_transform_4x4_luma_add_8_sse4':
libavcodec/x86/hevc_idct_sse4.c:33:5: error: unknown type name '__m128i'
libavcodec/x86/hevc_idct_sse4.c:35:5: warning: implicit declaration of function '_mm_set1_epi32' [-Wimplicit-function-declaration]
libavcodec/x86/hevc_idct_sse4.c:37:5: warning: implicit declaration of function '_mm_load_si128' [-Wimplicit-function-declaration]
libavcodec/x86/hevc_idct_sse4.c:37:26: error: '__m128i' undeclared (first use in this function)
libavcodec/x86/hevc_idct_sse4.c:37:26: note: each undeclared identifier is reported only once for each function it appears in
libavcodec/x86/hevc_idct_sse4.c:37:35: error: expected expression before ')' token
libavcodec/x86/hevc_idct_sse4.c:38:35: error: expected expression before ')' token

The issue is solved now. We patched our "Toolchain-mingw32.cmake" file to add one more variable as follows:
SET(CMAKE_SYSTEM_PROCESSOR i686)

After that we patched "CMakeLists.txt" file so that, if ${CMAKE_SYSTEM_PROCESSOR} is equal to "i686" and at the same time ${CMAKE_SYSTEM_NAME} is equal to "Windows", we will set variable "YASM_ARGS" as follows:
-f win32 -DPIC -DX86_32 -DPREFIX -I ${CMAKE_CURRENT_SOURCE_DIR} -I./ -P${CMAKE_CURRENT_SOURCE_DIR}/config.asm -I ${CMAKE_CURRENT_SOURCE_DIR}/libavfilter/x86/ -I ${CMAKE_CURRENT_SOURCE_DIR}/libavutil/x86/

After this two patches, it compiled smoothly. Need to test the library generated.

weird that smarter's suggestion does not work by default, but it is nice that you get it working by yourself