Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android compilation error #137

Closed
bartekkr opened this issue Sep 15, 2017 · 8 comments
Closed

Android compilation error #137

bartekkr opened this issue Sep 15, 2017 · 8 comments
Labels
1.2 Related to older version of minizip 1.2 compilation Issues related to compiling source code fixed Issue or bug has been fixed

Comments

@bartekkr
Copy link

bartekkr commented Sep 15, 2017

Hi, I am using following NDK:

builder@dev-workstation:~/minizip-scratchpad$ arm-linux-androideabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-androideabi-gcc
COLLECT_LTO_WRAPPER=/work/android-sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper
Target: arm-linux-androideabi
Configured with: /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install --with-mpfr=/buildbot/tmp/build/toolchain/temp-install --with-mpc=/buildbot/tmp/build/toolchain/temp-install --with-cloog=/buildbot/tmp/build/toolchain/temp-install --with-isl=/buildbot/tmp/build/toolchain/temp-install --with-ppl=/buildbot/tmp/build/toolchain/temp-install --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array --disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot --with-binutils-version=2.25 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none --with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x --with-bugurl=http://source.android.com/source/report-bugs.html --enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default
Thread model: posix
gcc version 4.9.x 20150123 (prerelease) (GCC)

when i configure minizip, using cmake command:

cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/work/libextern/android_armv7-a_gcc_4.9.0/minizip-1-1 -DDEF_ZLIB_ROOT=/work/libextern/android_armv7-a_gcc_4.9.0/zlib-1-2-11 -DBUILD_TEST=ON -DCMAKE_TOOLCHAIN_FILE=/work/libextern/android_armv7-a_gcc_4.9.0/toolchain.file.cmake ../minizip

with following toolchain file:
set(CMAKE_SYSTEM_NAME Android)

set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
set(CMAKE_ANDROID_NDK $ENV{ANDROID_NDK_BIN}/../../../../..)
set(CMAKE_SYSROOT $ENV{ANDROID_NDK_BIN}/../../../../../platforms/android-16/arch-arm)

set(CMAKE_FIND_ROOT_PATH /work/libextern/android_armv7-a_gcc_4.9.0 $ENV{ANDROID_NDK_BIN}/../../../../../platforms/android-16/arch-arm)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

cmake version: 3.8.0

and built it, then i have following linker errors:

/home/builder/minizip/miniunz.c:221: error: undefined reference to 'fopen64'
/home/builder/minizip/miniunz.c:230: error: undefined reference to 'fopen64'
/home/builder/minizip/minishared.c:219: error: undefined reference to 'fopen64'
/home/builder/minizip/minishared.c:229: error: undefined reference to 'fopen64'
/home/builder/minizip/minishared.c:234: error: undefined reference to 'fseeko64'
/home/builder/minizip/minishared.c:235: error: undefined reference to 'ftello64'
/home/builder/minizip/ioapi.c:297: error: undefined reference to 'fseeko64'
/home/builder/minizip/ioapi.c:239: error: undefined reference to 'ftello64'

it would be nice to fix it ;)

(zlib exists and is correctly built)

bartek

@Coeur
Copy link
Contributor

Coeur commented Sep 15, 2017

Hi bartek, and thank you for trying minizip.

A search on define fopen64 leads us to ioapi.h for its definition. It is well defined when any of those conditions are also defined:

  • USE_FILE32API
  • __FreeBSD__
  • __NetBSD__
  • __DragonFly__
  • __OpenBSD__
  • __APPLE__
  • _MSC_VER

Well, no Android in the list.

Maybe adding this would fix your issue:

#ifdef __ANDROID__
#  define fopen64 fopen
#  ifdef __USE_FILE_OFFSET64
#    define ftello64 ftello
#    define fseeko64 fseeko
#  else
#    define ftello64 ftell
#    define fseeko64 fseek
#  endif
#endif

But will it be compatible with __ANDROID_API__ lower than __ANDROID_API_N__, as asked in this issue?

@Coeur
Copy link
Contributor

Coeur commented Sep 15, 2017

@bartekkr I made a branch on my fork with such macro added, can you test it? https://github.com/Coeur/minizip/tree/android

@bartekkr
Copy link
Author

Hi, thank you for reply
i will do it soon and will let you know
i am out of home now
(i am using ANDROID_API_J that is lower than required, so may it work not correctly)

@Coeur
Copy link
Contributor

Coeur commented Sep 15, 2017

It should be OK actually, as either you're not using Unified Headers (and you're not concerned by the issue), or you're using Unified Headers but building for 32 bits only (and you're not concerned by the issue), or you're in a configuration that won't build at all and with Android specific errors. Well, that's what I understood from aosp-mirror/platform_bionic@00fedf5.

Please note that I have never developed for Android yet.

@bartekkr
Copy link
Author

bartekkr commented Sep 15, 2017

That works (project can be built), thanks! (maybe merge master to android?)

@bartekkr
Copy link
Author

i will use libminizip in my project and will let you know if it works

@Coeur Coeur mentioned this issue Sep 15, 2017
@Coeur
Copy link
Contributor

Coeur commented Sep 15, 2017

I turned it into a pull request. It's in the hands of @nmoinvaz now.

@bartekkr
Copy link
Author

works on android correctly

skhrshin added a commit to flokart-world/minizip that referenced this issue Oct 16, 2017
@nmoinvaz nmoinvaz added 1.2 Related to older version of minizip 1.2 compilation Issues related to compiling source code fixed Issue or bug has been fixed labels Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.2 Related to older version of minizip 1.2 compilation Issues related to compiling source code fixed Issue or bug has been fixed
Projects
None yet
Development

No branches or pull requests

3 participants