I've a big C file 400M approx. The file size is due to big resources within the code itself. I'm trying to compile with MinGW32 but with the mingw32-gcc.exe -O0 -g3 -ggdb3 -o file.exe file.c
but the compiler shows me this error cc1.exe: out of memory allocating #N bytes
. How can I solve this problem?
Since your ACTUAL problem is that you need a huge executable, the solution is something completely different from what you tried, and this is why you always should tell what your actual problem is, instead of assuming that your attempt is correct or suitable. As mentioned in the comments, this is an XY-problem
Here is a pretty easy solution. First, create the boilerplate for an assembly program. On my computer, using Linux and nasm it looks like this:
section .text
global _start
_start:
I named this file nop.asm
Now, I used a simple bash loop to add 10 million nop:s:
$ for i in $(seq 10000000); do echo nop >> nop.asm ; done
Add the rest of the boilerplate:
$ echo "mov eax,1" >> nop.asm
$ echo "int 0x80" >> nop.asm
Note: The boilerplate may look different on your system
Now you will have a file called nop.asm that looks like this:
section .text
global _start
_start:
nop
nop
...
nop
nop
mov eax,1
int 0x80
Compile and link it:
$ nasm -f elf64 nop.asm
$ ld -s -o nop nop.o
And now you have a pretty big binary:
$ ls -lh
total 94M
-rwxr-xr-x 1 klutt klutt 16M Oct 30 21:35 nop
-rw-r--r-- 1 klutt klutt 63M Oct 30 21:33 nop.asm
-rw-r--r-- 1 klutt klutt 16M Oct 30 21:34 nop.o
If I would get the same problem with nasm as you got with gcc, I would consider writing a program that writes the executable directly.