Posted: Tue Nov 06, 2007 10:24 am
Didn't you read my post? You need to setup a cross-compiler..
Look at the Wiki article I posted...
Look at the Wiki article I posted...
The Place to Start for Operating System Developers
https://f.osdev.org/
Firstly, I would suggest reading Brynets post. Secondly, I think that the reason for that is you still have the MinGW version of GCC somewhere in your PATH environment variable. As Cygwin includes your Windows PATH variable in the Bash PATH variable, you are using the wrong version of GCC.XCHG wrote:By the way, I just looked at the output object file that GCC produced and it is clearly a Win32 PE file.
Well I already have looked at the Wiki link that you provided but to me it is useless. I have installed GCC utilities in Windows and my whole OS Development environment is in Windows. In that article, it is assumed that my OS Development environment is in *nix. I don't need that really What I want to know is for someone to tell me, since I have not programmed a working project in C before, what I have to do step by step to get GCC to give me a flat binary output. I am asking a straightforward question and I am expecting an answer as straightforward as that. Not like "First you download Cygwin and then you control the temperature of the sun with that. Well that is useless so what you have to do is to download this package and that which are basically useless. So you will have to start from scratch. Oh by the way, GCC won't produce flat binary files. I'm sorry!"Brynet-Inc wrote:Didn't you read my post? You need to setup a cross-compiler..
Look at the Wiki article I posted...
3) I do havegcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
GNU objcopy 2.17.50 20060817
If you follow the instructions for producing a Cross Compiler word for word then you will get what you want. The instructions work in cygwin just fine. In fact I think they are pretty much written for cygwin. Now go though the instructions step by step. If you encounter any problems or need any help just ask, but at least try.XCHG wrote:For me (who hasn't programmed a working project in C before), they are not straightforward enough However, I appreciate your help.
As frank already pointed out, the GCC Cross-Compiler tutorial in the Wiki was written for Cygwin users.XCHG wrote:Well I already have looked at the Wiki link that you provided but to me it is useless. I have installed GCC utilities in Windows and my whole OS Development environment is in Windows. In that article, it is assumed that my OS Development environment is in *nix.
XCHG wrote: Then when I try to link the "c1.o" and make a flat binary file, I get this error:
Could anybody tell me what I am doing wrong, please?Code: Select all
C:\c>ld -T link.ld c1.o -o c1.bin ld: cannot perform PE operations on non PE output file 'c1.bin'.
In the Wiki, I wrote: Why an OS developer should build a cross-compiler
Creating a dedicated (cross-) compiler for your OS development work can save you many headaches. If...
- ...your system compiler drags in references to alloca() or other OS-dependent things,
- ...Cygwin complains about "PE operation on non-PE file",
- ...
Code: Select all
root@vandadpc ~
$ export PREFIX=/usr/cross
root@vandadpc ~
$ export TARGET=i586-elf
root@vandadpc ~
$ cd /usr/src
root@vandadpc /usr/src
$ mkdir build-binutils build-gcc
root@vandadpc /usr/src
$ cd /usr/src/build-binutils
root@vandadpc /usr/src/build-binutils
$ ../binutils-2.16.1/configure --target=$TARGET --prefix=$PREFIX --disable-nls
creating cache ./config.cache
checking host system type... i686-pc-cygwin
checking target system type... i586-pc-elf
checking build system type... i686-pc-cygwin
checking for a BSD compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for gnatbind... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... tail +16c $$f1 > tmp-foo1; tail
+16c $$f2 > tmp-foo2; cmp tmp-foo1 tmp-foo2
checking for correct version of gmp.h... no
checking for bison... no
checking for bison... no
checking for byacc... no
checking for yacc... no
checking for gm4... no
checking for gnum4... no
checking for m4... no
checking for flex... no
checking for flex... no
checking for lex... no
checking for makeinfo... makeinfo
checking for i686-pc-cygwin-ar... no
checking for ar... ar
checking for i686-pc-cygwin-as... no
checking for as... as
checking for i686-pc-cygwin-dlltool... no
checking for dlltool... dlltool
checking for i686-pc-cygwin-ld... /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../
i686-pc-cygwin/bin/ld.exe
checking for i686-pc-cygwin-nm... no
checking for nm... nm
checking for i686-pc-cygwin-ranlib... no
checking for ranlib... ranlib
checking for i686-pc-cygwin-windres... no
checking for windres... windres
checking for i686-pc-cygwin-objcopy... no
checking for objcopy... objcopy
checking for i686-pc-cygwin-objdump... no
checking for objdump... objdump
checking for i586-elf-ar... no
checking for i586-elf-as... no
checking for i586-elf-dlltool... no
checking for i586-elf-ld... no
checking for i586-elf-nm... no
checking for i586-elf-ranlib... no
checking for i586-elf-windres... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking if symbolic links between directories work... ../binutils-2.16.1/config
ure: line 4866: cmp: command not found
no
../binutils-2.16.1/configure: line 4962: cmp: command not found
updating cache ./config.cache
creating ./config.status
creating Makefile
root@vandadpc /usr/src/build-binutils
$ make all
MAKE Version 5.2 Copyright (c) 1987, 1998 Inprise Corp.
Error makefile 187: Command syntax error
Error makefile 191: Command syntax error
Fatal makefile 10203: No terminator specified for in-line file operator
root@vandadpc /usr/src/build-binutils
$
Have you read Brynet-Inc.'s post? Both MingW and Cygwin are targeted at creating Windows executables, with all kinds of problems attached when you try to output flat binary, or ELF.XCHG wrote:Solar,
I have already read those but I don't see what your point is and how it is connected to my problem.
Sanitize your environment variables!!XCHG wrote:MAKE Version 5.2 Copyright (c) 1987, 1998 Inprise Corp.
YIKES! I missed that one... with an environment like that, you can't be at all sure what tools ./configure drags to your doorstep... check Cygwin's PATH, and throw out everything that doesn't belong. Then use "set" to have a look at your environment, and again throw away any crud from other, unrelated environments...Brynet-Inc wrote:XCHG wrote:MAKE Version 5.2 Copyright (c) 1987, 1998 Inprise Corp.