How to solve Debian 64-bit system and 32-bit system programs cannot open files larger than 2 GB

Source: Internet
Author: User
In 64-bit Linux, how does one run a 32-bit application? In the case of 32-bit programs, it is advantageous to use a 32-bit system and use RAMDISK to allocate unrecognized memory to the hard disk for virtual memory! Although the 64-bit system can recognize more than 3 GB memory, it cannot make 32-bit programs use more than 3 GB memory! With more than 3 GB of memory, we can only rely on 64-bit systems and 64-bit programs! Preface

The online business is a 32-bit program, and the server uses Debian 64-bit. In theory, the ext4 file system supports a maximum of 16 TB for a single file. Because program logs are not classified by time, so that a single file reaches 2 GB, logs may be lost in some time periods due to the failure to write results. The final analysis shows that the 32-bit program references the 32-bit library, and fopen cannot be written after a single file reaches 32 GB.

I. Definition macro
  • Define the macro to process large files (> 4 GB) (This macro definition must be introduced wherever it is used. So you need to write it in a. h file separately)
  #undef   _FILE_OFFSET_BITS     #define   _FILE_OFFSET_BITS   64     #include   
  
        #include   
   
  
2. Add the makefile compilation Option -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE

(Qt can be modified in the pro file.DEFINES += _FILE_OFFSET_BITS=64 _LARGE_FILE, Parameters in the preceding format are automatically generated in makefile)

Iii. Use fopen64 function 4. Add a parameter to functions such as fopen:
  • For open and open, you can use the O_LARGEFILE parameter,
  • That is:fd = open("./bill_test",O_LARGEFILE|O_APPEND|O_RDWR,0666); 
    Then there is no problem, but fopen does not have this parameter, and it can only be solved according to the method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.