gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
62 stars 50 forks source link

I can't get this to build using Android NDK #85

Closed Stuggy closed 3 years ago

Stuggy commented 4 years ago

I'm on Windows 10 with the Android NDK r21.

I'm trying to build Android libraries and am getting all kinds of errors related unknown types for int etc.

I'm guessing there is a define I need to use or could it be that zziplib isn't correctly set up for this build environment?

Some examples: [armeabi-v7a] Compile thumb : zziplib <= fetch.c In file included from S:/And2020/zziplib/jni/zzip/fetch.c:13: In file included from S:/And2020/zziplib/jni\zzip/fetch.h:4: In file included from S:/And2020/zziplib/jni\zzip/types.h:26: In file included from S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\fcntl.h:33: In file included from S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\sys/types.h:39: S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/pthread_types.h:36:3: error: unknown type name 'uint32_t' uint32_t flags; ^ S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/pthread_types.h:40:3: error: unknown type name 'int32_t' int32_t sched_policy; ^ S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/pthread_types.h:41:3: error: unknown type name 'int32_t' int32_t sched_priority; ^ S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/pthread_types.h:65:3: error: unknown type name 'int32_t' int32_t __private[1]; ^ S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/pthread_types.h:77:3: error: unknown type name 'int32_t' int32_t __private[1]; ^ S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/pthread_types.h:89:3: error: unknown type name 'int32_t' int32_t __private[10]; ^ In file included from S:/And2020/zziplib/jni/zzip/fetch.c:13: In file included from S:/And2020/zziplib/jni\zzip/fetch.h:4: In file included from S:/And2020/zziplib/jni\zzip/types.h:26: In file included from S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\fcntl.h:33: S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\sys/types.h:48:9: error: unknown type name 'uint32_t' typedef uint32_t __id_t; ^ S:/NDK-r21/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\sys/types.h:72:9: error: unknown type name 'uint64_t' typedef uint64_t ino64_t;

gdraheim commented 4 years ago

That should be a cross-compiler, isn't it?

Actually, both autoconf and cmake should be able to detect that. What build system do you use?

Grimler91 commented 3 years ago

The actual problem seem to be the one described in ax_prefix_config_h.m4, zzip/_config.h contains entries like:

/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
   */
#ifndef ZZIP_^A
#define ZZIP_^A ^B
#endif

I tried changing ax_prefix_config_h.m4 to the latest one from the autoconf macro archive but it does not seem to make a difference. I have tested with libtool 2.4.6.

Using cmake instead of the configure and make works though (and that is recommended to use according to the README anyways)

Stuggy commented 3 years ago

I'm actually trying to get a NDK build script (Android.mk) to work using Windows and I still can't get it to work. Because I am doing it directly do I need to change some define in a config file or something?

An example error: [armeabi-v7a] Compile thumb : zzip <= dir.c In file included from S:\OGRE1.12\Build32\zziplib-0.13.71\zzip\dir.c:9: In file included from S:\OGRE1.12\Build32\zziplib-0.13.71\zzip/lib.h:16: In file included from S:\OGRE1.12\Build32\zziplib-0.13.71\zzip/zzip.h:17: In file included from S:\OGRE1.12\Build32\zziplib-0.13.71\zzip/types.h:26: In file included from C:/Android/SDK/ndk/22.1.7171670/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\fcntl.h:38: In file included from C:/Android/SDK/ndk/22.1.7171670/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\sys/types.h:39: C:/Android/SDK/ndk/22.1.7171670/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include\bits/pthread_types.h:35:3: error: unknown type name 'uint32_t' uint32_t flags; ^

gdraheim commented 3 years ago

Let's be clear, the uint32_t comes from C99 stdint.h - that file should be included at some point.

The zzip/dir.c goes to zzip/lib.h which does always include stdint.h - but may be too late as zzip/zzip.h comes before and it includes zzip/types.h which includes sys/types.h which includes pthread_types.h

The real problem seems to be in the pthread_types.h which uses a type definition that it did not include. On my Linux system, neither pthreadtypes.h nor pthread.h make use of bit-correct stdint.h types. It's a specialty of your target where the header files are broken - you should actually complain to the upstream libc maintainers.

Surely we can make a workaround for the situation but I am not sure if it is worth it. It would look like a patch to zzip/types.h that includes right before <sys/types.h>

-

Last word: please do not use the automake/autoconf stuff anymore, always use the cmake variant. I don't think it will help in this case but I am not going to look into the details of the older build system anymore which will get removed in the next release.

Stuggy commented 3 years ago

Thanks for the reply. I did get it to finally build before your comment. I had included stdint.h and I think I was still getting errors. I ended up removing one file from the compilation and at least was able to get a library built which seems so far to have enough functions to continue.

I think that we can mark this as closed for now even though I wasn't able to create a full clean ndk-build.