I try build binary file with MinGw32 but i have 2 problems
- ld seems doesn't work with the -e xxx option
- and the binary file produced is finaly not a binary file , it's a win 32 file
i use this 2 commande lines :
gcc -c -o ./gdos/kernel/kernel.o ./gdos/kernel/kernel.c
ld -o ./gdos/bin/kernel.bin -e main --format=binary ./gdos/kernel/kernel.o
i have this result :
ld: warning: cannot find the entry symbol main; defaulting to 00030000
Is someone have a solution ?
Build binary file with MinGw32
Re:Build binary file with MinGw32
Try -e _main.gedeon wrote:- ld seems doesn't work with the -e xxx option
Try the -b or --format option. Alternatively, link to PE format, then use objcopy to convert to binary.- and the binary file produced is finaly not a binary file , it's a win 32 file
Re:Build binary file with MinGw32
i already tried _main it was the same
and with other format pe-i386 or elf32-386 i have undefined reference to _alloca and __main
i'm tired of this tools that never work
Maybe i could try cygwin but i'm afraid that was the same problem
and with other format pe-i386 or elf32-386 i have undefined reference to _alloca and __main
i'm tired of this tools that never work
Maybe i could try cygwin but i'm afraid that was the same problem
Re:Build binary file with MinGw32
The _alloca/__main problem is easy.
Calls to _alloca are inserted by gcc on Windows for functions whose local variables are bigger than 4096 bytes; it should generally be possible to avoid this. gcc also inserts a call to __main at the beginning of main; it's OK to write your own version of __main which doesn't do anything.
If you decide you do want _alloca, link against libgcc.a, which should have been provided with gcc.
Calls to _alloca are inserted by gcc on Windows for functions whose local variables are bigger than 4096 bytes; it should generally be possible to avoid this. gcc also inserts a call to __main at the beginning of main; it's OK to write your own version of __main which doesn't do anything.
If you decide you do want _alloca, link against libgcc.a, which should have been provided with gcc.
Re:Build binary file with MinGw32
thanks
step by step ....
Now i have a new problem (another one)
i want to use libgcc.a with this command line :
ld -e _main -Ttext 0x030000 -b pe-i386 ./gdos/kernel/kernel.o -L ./gdos/lib -l libgcc.a
and the result is ......
l: cannot find -llibgcc.a
so the path is the good one and the file libgcc.a is present in the directory
so what the matter ?
i also tried with -l ./gdos/lib/gcclib.a but the error message is the same
step by step ....
Now i have a new problem (another one)
i want to use libgcc.a with this command line :
ld -e _main -Ttext 0x030000 -b pe-i386 ./gdos/kernel/kernel.o -L ./gdos/lib -l libgcc.a
and the result is ......
l: cannot find -llibgcc.a
so the path is the good one and the file libgcc.a is present in the directory
so what the matter ?
i also tried with -l ./gdos/lib/gcclib.a but the error message is the same
Re:Build binary file with MinGw32
I had to use a command line like this:
[tt]-lgcc -L/lib/gcc-lib/i686-pc-cygwin/3.2[/tt]
I use gcc 3.2 on Cygwin, so this is the right path for me.
[tt]-lgcc -L/lib/gcc-lib/i686-pc-cygwin/3.2[/tt]
I use gcc 3.2 on Cygwin, so this is the right path for me.
Re:Build binary file with MinGw32
To be sure i have reintalled Cygwin on cdrive, it was on e drive
i have no command like lgcc
but when i try tris command in my makefile
ld -e _main -Ttext 0x030000 -b pe-i386 ./gdos/kernel/kernel.o -L\lib\gcc-lib\i686-pc-cygwin\3.3.1
its the same result and i don't understand
the only differnece is the gcc version
i have no command like lgcc
but when i try tris command in my makefile
ld -e _main -Ttext 0x030000 -b pe-i386 ./gdos/kernel/kernel.o -L\lib\gcc-lib\i686-pc-cygwin\3.3.1
its the same result and i don't understand
the only differnece is the gcc version
Re:Build binary file with MinGw32
OK, maybe I haven't been 100% clear.
Here is the actual command I use to link things.
[tt]ld -o ../../../distrib/tetris.exe \
objects/tetris.o \
../../../lib/crt0.o ../../../lib/framebuf_user.lib ../../../lib/libc.lib ../../../lib/libsys.lib \
-lgcc -L/lib/gcc-lib/i686-pc-cygwin/3.2[/tt]
Modify this as appropriate for your build system.
Here is the actual command I use to link things.
[tt]ld -o ../../../distrib/tetris.exe \
objects/tetris.o \
../../../lib/crt0.o ../../../lib/framebuf_user.lib ../../../lib/libc.lib ../../../lib/libsys.lib \
-lgcc -L/lib/gcc-lib/i686-pc-cygwin/3.2[/tt]
Modify this as appropriate for your build system.
Re:Build binary file with MinGw32
thanks for your help and for your patience, it works !
PS : there is few documentation on -lgcc ( or lc )
PS : there is few documentation on -lgcc ( or lc )