ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Originally posted by Nerox Hello there, i'm trying to create a 8GB file in size, but i cannot do that with the traditional fopen() function. Any ideas?
Thanks in Adavance.
Whats kind of your partition? Does your system support 64-bit file operations (large file support)? Is there a quota limitation?
but, if I write a similar program in c++ and compile it with the exact same options using g++, then I receive a 'file size limit exceeded' message when the output file reaches the 2GB limit.
Can anyone recommend either a compiler option or some other option in which I can generate large files (>2GB) using the C++ compiler (in this case the g++ compiler).
Most of the glibc file functions have a 64-bit version with "64" appended to the name. I think this will alter the size type used, so you might need to use a 64-bit integer for size and offset values. If you look at info libc and find a function such as open you should see a variant such as open64.
ta0kira
I am opening the file using ofstream, and when I write to this file, at the point where it exceeds the 2GB limit, I get the error "filesize limit exceeded".
I have tried all the options as presented in my original post, but I can not seem to get the g++ compiler to generate the correct code to create large datafiles.
I am opening the file using ofstream, and when I write to this file, at the point where it exceeds the 2GB limit, I get the error "filesize limit exceeded".
I'm pretty sure ofstream is stuck with the register size of the architecture. While it's a portable way to deal with files in the C++ realm, with glibc available I think you're better off just using C to deal with huge files.
ta0kira
If you still have problems creating files larger than 2GB, you might want to check to see that you are authorized to create one larger. See man getrlimit.
ta0kira
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.