El Divendres, 26 d'abril de 2013, a les 01:24:41, Fabio D'Urso va escriure:
> Hi,

Hi

> 
> I compile poppler via CMake and, if I try to open a large file (>2 GB) on my
> 32-bit linux system, I get the following error:
>  Error: Couldn't open file 'big.pdf': Value too large for defined data type.
> 
> Turns out that open() refuses to open large files unless
>  #define _FILE_OFFSET_BITS 64
> is defined.
> 
> So I've checked how config.h is generated and I noticed that only autotool's
> config.h.in defines _FILE_OFFSET_BITS.
> CMake's config.h.cmake has this and a few similar macros commented out:
> 
>  /* Number of bits in a file offset, on hosts where this is settable. */
>  /* #undef _FILE_OFFSET_BITS */
> 
>  /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
>  /* #undef _LARGEFILE_SOURCE */
> 
>  /* Define for large files, on AIX-style hosts. */
>  /* #undef _LARGE_FILES */
> 
> On my system, manually setting #define _FILE_OFFSET_BITS 64
> in the generated config.h file is enough to make LFS work.
> 
> Unfortunately, cmake stuff is out of my comfort zone, so I can't write a
> proper patch myself :(

Can you try the following patch and tell me if it helps?

Cheers,
  Albert

> 
> Fabio
> 
> _______________________________________________
> poppler mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/poppler
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 67d024e..28358ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,8 @@ include(MacroBoolTo01)
 find_package(Threads)
 include(TestBigEndian)
 test_big_endian(WORDS_BIGENDIAN)
+include(CheckFileOffsetBits)
+CHECK_FILE_OFFSET_BITS()
 
 set(POPPLER_MAJOR_VERSION "0")
 set(POPPLER_MINOR_VERSION "23")
diff --git a/cmake/modules/CheckFileOffsetBits.c b/cmake/modules/CheckFileOffsetBits.c
new file mode 100644
index 0000000..d948fec
--- /dev/null
+++ b/cmake/modules/CheckFileOffsetBits.c
@@ -0,0 +1,14 @@
+#include <sys/types.h>
+
+#define KB ((off_t)1024)
+#define MB ((off_t)1024 * KB)
+#define GB ((off_t)1024 * MB)
+#define TB ((off_t)1024 * GB)
+int t2[(((64 * GB -1) % 671088649) == 268434537)
+       && (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1];
+
+int main()
+{
+  ;
+  return 0;
+}
diff --git a/cmake/modules/CheckFileOffsetBits.cmake b/cmake/modules/CheckFileOffsetBits.cmake
new file mode 100644
index 0000000..b347c93
--- /dev/null
+++ b/cmake/modules/CheckFileOffsetBits.cmake
@@ -0,0 +1,44 @@
+# - Check if _FILE_OFFSET_BITS macro needed for large files
+# CHECK_FILE_OFFSET_BITS ()
+#
+# The following variables may be set before calling this macro to
+# modify the way the check is run:
+#
+#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
+#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+#  CMAKE_REQUIRED_INCLUDES = list of include directories
+# Copyright (c) 2009, Michihiro NAKAJIMA
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+#INCLUDE(CheckCXXSourceCompiles)
+
+GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits
+	 "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+MACRO (CHECK_FILE_OFFSET_BITS)
+  IF(NOT DEFINED _FILE_OFFSET_BITS)
+    MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files")
+    TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64
+      ${CMAKE_CURRENT_BINARY_DIR}
+      ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
+      COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
+    IF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
+      TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64
+        ${CMAKE_CURRENT_BINARY_DIR}
+        ${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
+        COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
+    ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
+
+    IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
+      SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
+      MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - needed")
+    ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
+      SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
+      MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed")
+    ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
+  ENDIF(NOT DEFINED _FILE_OFFSET_BITS)
+
+ENDMACRO (CHECK_FILE_OFFSET_BITS)
+
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to