Page 1 of 1
Build binary file with MinGw32
Posted: Fri Nov 21, 2003 9:43 am
by gedeon
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 ?
Re:Build binary file with MinGw32
Posted: Fri Nov 21, 2003 11:29 am
by Tim
gedeon wrote:- ld seems doesn't work with the -e xxx option
Try -e _main.
- and the binary file produced is finaly not a binary file , it's a win 32 file
Try the -b or --format option. Alternatively, link to PE format, then use objcopy to convert to binary.
Re:Build binary file with MinGw32
Posted: Fri Nov 21, 2003 11:45 am
by gedeon
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
Re:Build binary file with MinGw32
Posted: Fri Nov 21, 2003 2:40 pm
by Tim
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.
Re:Build binary file with MinGw32
Posted: Sat Nov 22, 2003 6:30 am
by gedeon
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
Re:Build binary file with MinGw32
Posted: Sat Nov 22, 2003 7:51 am
by Tim
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.
Re:Build binary file with MinGw32
Posted: Sun Nov 23, 2003 12:38 pm
by gedeon
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
Re:Build binary file with MinGw32
Posted: Sun Nov 23, 2003 2:28 pm
by Tim
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.
Re:Build binary file with MinGw32
Posted: Mon Nov 24, 2003 5:53 am
by gedeon
thanks for your help and for your patience, it works !
PS : there is few documentation on -lgcc ( or lc )