0

I have downloaded the libjpeg-turbo library from https://github.com/libjpeg-turbo/libjpeg-turbo/ and executed the below CMake commands in Ubuntu 16.04:

$ cd {path of my libjpeg-turbo library}
$ cmake -G"Unix Makefiles" {path of my libjpeg-turbo library}
$ make

It then generated libjpeg.a, libjpeg.so, libjpeg.so.62, libjpeg.so.62.3.0, libjpegturbo.a, libjpegturbo.so, libjpegturbo.so.0, libjpegturbo.so.0.2.0 etc

Now I'm trying to generate the libjpeg-turbo.so files for different CPU architectures.

For arm64-v8a:

$ cd {path of my libjpeg-turbo library}
$ cmake -G"Unix Makefiles" \
      -DANDROID_ABI=arm64-v8a \
      -DANDROID_ARM_MODE=arm \
      -DANDROID_PLATFORM=android-${21} \
      -DANDROID_TOOLCHAIN=${gcc} \
      -DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${21}" \
      -DCMAKE_TOOLCHAIN_FILE=${path of my ndk library}/build/cmake/android.toolchain.cmake \
       {path of my libjpeg-turbo library}

Output:

-- CMAKE_BUILD_TYPE = Release
-- VERSION = 2.0.3, BUILD = 20190703
-- 64-bit build (x86_64)
-- CMAKE_INSTALL_PREFIX = /opt/libjpeg-turbo
-- CMAKE_INSTALL_BINDIR = bin (/opt/libjpeg-turbo/bin)
-- CMAKE_INSTALL_DATAROOTDIR =  (/opt/libjpeg-turbo)
-- CMAKE_INSTALL_DOCDIR = doc (/opt/libjpeg-turbo/doc)
-- CMAKE_INSTALL_INCLUDEDIR = include (/opt/libjpeg-turbo/include)
-- CMAKE_INSTALL_LIBDIR = lib64 (/opt/libjpeg-turbo/lib64)
-- CMAKE_INSTALL_MANDIR = man (/opt/libjpeg-turbo/man)
-- Shared libraries enabled (ENABLE_SHARED = 1)
-- Static libraries enabled (ENABLE_STATIC = 1)
-- 12-bit JPEG support disabled (WITH_12BIT = 0)
-- Arithmetic decoding support enabled (WITH_ARITH_DEC = 1)
-- Arithmetic encoding support enabled (WITH_ARITH_ENC = 1)
-- TurboJPEG API library enabled (WITH_TURBOJPEG = 1)
-- TurboJPEG Java wrapper disabled (WITH_JAVA = 0)
-- In-memory source/destination managers enabled (WITH_MEM_SRCDST = 1)
-- Emulating libjpeg API/ABI v6.2 (WITH_JPEG7 = 0, WITH_JPEG8 = 0)
-- libjpeg API shared library version = 62.3.0
-- Compiler flags =  -O3 -DNDEBUG
-- Linker flags =  
-- Compiler supports pointers to undefined structures.
-- INLINE = __inline__ __attribute__((always_inline)) (FORCE_INLINE = 1)
-- Linker supports GNU-style version scripts
-- CMAKE_EXECUTABLE_SUFFIX = 
-- CMAKE_ASM_NASM_COMPILER = /usr/bin/nasm
-- CMAKE_ASM_NASM_OBJECT_FORMAT = elf64
-- CMAKE_ASM_NASM_FLAGS =  -DELF -D__x86_64__ -DPIC 
-- SIMD extensions: x86_64 (WITH_SIMD = 1)
-- FLOATTEST = sse
-- RPM architecture = x86_64, DEB architecture = amd64
-- Configuring done
-- Generating done
-- Build files have been written to: {path of my libjpeg-turbo library}

$ make

Output:

[  8%] Built target simd
[ 26%] Built target turbojpeg
[ 27%] Built target tjexample
[ 46%] Built target turbojpeg-static
[ 48%] Built target tjunittest-static
[ 64%] Built target jpeg-static
[ 65%] Built target wrjpgcom
[ 68%] Built target djpeg-static
[ 69%] Built target tjbench
[ 71%] Built target cjpeg-static
[ 72%] Built target tjunittest
[ 74%] Built target jpegtran-static
[ 75%] Built target rdjpgcom
[ 76%] Built target tjbench-static
[ 92%] Built target jpeg
[ 93%] Built target jpegtran
[ 96%] Built target djpeg
[ 97%] Built target jcstest
[ 99%] Built target cjpeg
[100%] Built target md5cmp

Similarly, I get a similar output when I execute for the armeabi-v7a architecture.

I do not get the .so files for the different architectures even though these three statements are printed:

-- Configuring done
-- Generating done
-- Build files have been written to: {path to my libjpeg-turbo library}

Could you please let me know how can I achieve generating the libjpeg-turbo.so files for the arm64-v8a, armeabi-v7a and armeabi architures?

Thank you.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Ingrid Cooper
  • 1,191
  • 3
  • 16
  • 27
  • If `path of my libjpeg-turbo library` means the same directory in all places, then you perform **in-source** build, with build directory (where you run `cmake`) equals to the source one (the last parameter to `cmake`). With such build type CMake generates build files only **once**, for a single target platform. Use **out-of-source** build, and use different build directories for different platforms. E.g. use `build-armeabi-v7a/` as a build subdirectory for `armeabi-v7a`, `build-arm64-v8a/` as a subdirectory for `arm64-v8a`. – Tsyvarev Jul 06 '19 at 08:22
  • Yes, I tried that too. Initially my build and source folders were the same which is the path of my libjpeg-turbo directory then I tried creating a "build" folder and in that path executed the **cmake** command but nothing is generating in that folder. In that path if I execute **make** then getting the error make: *** No targets specified and no makefile found. Stop. – Ingrid Cooper Jul 06 '19 at 08:41
  • Oh, you need to remove build files (`CMakeCache.txt` file, `CMakeFiles/` folder) from the source directory for make out-of-source builds avaiable again. Otherwise, when found these files in the source directory, CMake will always do *in-source* build. – Tsyvarev Jul 06 '19 at 11:38
  • I deleted the **CMakeCache.txt** and **CMakeFiles/** folder and executed the **cmake** command in my **/libjpeg-turbo-master/build-arm64-v8a** path but getting the error **CMake Error at /usr/share/cmake-3.5/Modules/CMakeDetermineSystem.cmake:104 (message): Could not find toolchain file: $/home/ingrid/Android/android-ndk-r16b/build/cmake/android.toolchain.cmake Call Stack (most recent call first): CMakeLists.txt:7 (project) CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!** – Ingrid Cooper Jul 06 '19 at 16:41
  • @Tsyvarev Could you please let me know how to resolve the above CMake error? The first time I generated the .so files I didn't get that error but now when I deleted the CMakeCache.txt and CMakeFiles/ folder I'm getting this. I searched a lot regarding this error but not able to find a solution for this. – Ingrid Cooper Jul 07 '19 at 06:04
  • It seems that you accidentally removed some of source files. If you cloned the repository with `git`, then run `git checkout .` for restore source files. – Tsyvarev Jul 07 '19 at 08:37
  • Oh, I didn't clone the repo but had downloaded from Github the libjpeg-turbo as a zip & extracted it. Even when I extract it freshly & run cmake in my build folder it is giving the error that it could not find the toolchain file although it is present in that path. I also tried without the **-DANDROID_TOOLCHAIN=${gcc}** & **-DCMAKE_TOOLCHAIN_FILE=${path of my ndk library}/build/cmake/android.toolchain.cmake \ {path of my libjpeg-turbo library}** options & then it generated the .so files etc but from the output it seems it is for x86-64 & ignored the **ABI, ARM_MODE, ASM_FLAGS** options – Ingrid Cooper Jul 07 '19 at 14:57
  • @Tsyvarev I fixed the toolchain not found issue by removing the $ before the path and it worked fine. I was able to successfully generate the .so files for the different CPU architectures. Thank you very much for all your help! – Ingrid Cooper Jul 10 '19 at 10:02

0 Answers0