kuba-- / zip

A portable, simple zip library written in C
MIT License
1.39k stars 272 forks source link

Failed to compile with Android Studio NDK r26b #329

Closed Haruma-VN closed 8 months ago

Haruma-VN commented 8 months ago

Sorry for bothering you but the library isn't build when I used Android Clang to compile the current project (MSVC works fine). Here is the image: image

I've rewritten the CMakeLists.txt to fits my will, here is my modified version:

cmake_minimum_required(VERSION 3.14)

project(
  zip
  LANGUAGES C
  VERSION "0.3.0"
)

add_definitions(-DZIP_ENABLE_SHARABLE_FILE_OPEN)

add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)
add_library(
  ${PROJECT_NAME} STATIC 
  ./miniz.h 
  ./zip.h 
  ./zip.c
)

set_property(TARGET ${PROJECT_NAME} PROPERTY C_VISIBILITY_PRESET hidden)

set(CMAKE_C_STANDARD 90)
if (MSVC)
  # Use secure functions by default and suppress warnings about "deprecated" functions
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_NONSTDC_NO_WARNINGS=1 /D _CRT_SECURE_NO_WARNINGS=1")

elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
        "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
        "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -pedantic")
endif (MSVC)

Can you help me solve the current solution, thanks a lot.

Haruma-VN commented 8 months ago

Sorry my bad, it seemed that the error comes from the line:

add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64)

After deleting it, the compiler starts compile normally. image

Sorry for unreasonable issue.