osamu620 / OpenHTJ2K

An open source implementation of ITU-T Rec.814 | ISO 15444-15 (a.k.a. HTJ2K).
BSD 3-Clause "New" or "Revised" License
36 stars 10 forks source link

Support for armv7-a architecture #158

Closed v2aus closed 6 months ago

v2aus commented 11 months ago

Hello. It seems that OpenHTJ2K now doesn't support armv7-a. I tried to modify the CmakeLists.txt to cross-compile the source code with GCC 6.3.0. Finally, I failed. I set CMAKE_CXX_STANDARD to 14 and CMAKE_HOST_SYSTEM_PROCESSOR to arm32, and then I added some code about CMAKE_HOST_SYSTEM_PROCESSOR matching arm32 to CmakeLists.txt. I set ENABLE_ARM_NEON to "OFF" because there is no definition of vaddv_u8(). I set -march=armv7-a -mtune=cortex-7a. At last, the compilation went to the following step:

[ 93%] Linking CXX executable bin/open_htj2k_enc bin/libopen_htj2k_R.so: undefined reference to std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)' bin/libopen_htj2k_R.so: undefined reference tostd::__atomic_futex_unsigned_base::_M_futex_wait_until(unsigned int*, unsigned int, bool, std::chrono::duration<long long, std::ratio<1ll, 1ll> >, std::chrono::duration<long long, std::ratio<1ll, 1000000000ll> >)' collect2: error: ld returned 1 exit status make[2]: [CMakeFiles/open_htj2k_enc.dir/build.make:85: bin/open_htj2k_enc] Error 1 make[1]: [CMakeFiles/Makefile2:276: CMakeFiles/open_htj2k_enc.dir/all] Error 2 make: *** [Makefile:141: all] Error 2

I'd like to know whether it is because something is wrong with my modification of the CmakeLists.txt, or the source code now does not support armv7-a.

osamu620 commented 10 months ago

Hi @v2aus ,

I'm sorry for not getting back to you sooner. This question in Stackoverflow seems to be relevant. https://stackoverflow.com/questions/46999056/crosscompile-undefined-reference-to-std-atomic-futex-unsigned-base-m-futex

Maybe commenting out the 'find_package(Threads)' line in CMakeLists.txt is a possible workaround because the error message seems to be related to multi-threading.

osamu620 commented 6 months ago

@v2aus

If you are on a Debian-based distro, the following workaround should work:

For example,

file build-32bit/bin/libopen_htj2k_R.so

returns

build-32bit/bin/libopen_htj2k_R.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=64c71389dd4b344e258df37e549ac8e4acbc5a2e, not stripped

and all the tests have been passed.