www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/08/24/20:32:13

Date: Fri, 24 Aug 2001 17:31:45 -0700 (PDT)
From: Will Robinson <wsr23 AT Stanford DOT EDU>
To: <djgpp AT delorie DOT com>
Subject: Re: linux->dos cross-compiler
In-Reply-To: <3B8644B9.22816.5F6E45@localhost>
Message-ID: <Pine.GSO.4.31.0108241212250.6574-100000@elaine10.Stanford.EDU>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> > Just FYI, I found that the offending assembler line is:
> >
> > .def __vptr$__basic_file<char>; .val 0; .scl 8; .type 01124; .endef
>
> Known problem
>
> I suggest looking for changes done for DJGPP port of gcc-3.0
> (see archive v2gnu/alphas/gcc30s2.zip) or more exactly for patch to
> gcc/sdbout.c.

Applying sdbout.c.diff allowed me to successfully finish compiling!  After
a "make install," I had gcc and g++ in my
/opt/djgpp/i586-pc-msdosdjgpp/bin directory.  And identical binaries like
/opt/djgpp/bin/i586-pc-msdosdjgpp-gcc.

Here's my current status:
  i586-pc-msdosdjgpp-gcc -o hello.exe hello.c
produces a valid executable that runs in a DOS window on win98 and prints
"Hello, world!"  The program still runs correctly if I change the
extension to .cpp and recompile with g++.  It looks like we're getting
close...

...but C++ is still not all there.  I enter this program as string.cpp:

   #include <string>

   int main()
   {
      string s = "yay!";
      return 0;
   }

and then try to compile it with i586-pc-msdosdjgpp-g++.  I get:

string.cpp: In function `int main()':
string.cpp:5: `string' undeclared (first use this function)
string.cpp:5: (Each undeclared identifier is reported only once for each
   function it appears in.)
string.cpp:5: parse error before `=' token

It's been a long road getting to this point, and I'd like to imagine that
I see the finish line.  I hope this isn't information overload, but I
repeated the steps I've taken to build the cross compiler as it is
currently, and carefully noted every little thing I did.  Below is the
sequence of steps I took (Tim, this might also help you get yours going if
you try to build one in the near future).

The steps that make me uneasy because of my incomplete understanding are
the ones between the gcc configure step and the gcc make step.  In short,
I edited a Makefile, patched sdbout.c, edited getpwd.c, and copied a bunch
of header files by hand.  The end result of "make" after these changes was
a cross compiler that is close to working.  My host system is Mandrake
8.0, pretty much right out of the box, and my linux compiler is gcc 2.96.
Here goes...

1. mkdir /opt/djgpp

2. chown -R wsr23.wsr23 /opt/djgpp

3. mkdir /opt/djgpp/i586-pc-msdosdjgpp

4. download djcrx203.zip from www.delorie.com

5. unzip -a djcrx203.zip (in /opt/djgpp/i586-pc-msdosdjgpp)

6. mkdir ~/temp

7. download binutils-2.11.2.tar.gz, gcc-3.0.1.tar.gz

8. untar binutils-2.11.2.tar.gz and gcc-3.0.1.tar.gz in ~/temp

9. cd ~/temp/binutils-2.11.2

10. mkdir djbuild

11. cd djbuild

12. ../configure --target=i586-pc-msdosdjgpp --prefix=/opt/djgpp

13. make

14. make install

15. cd ~/temp/gcc-3.0.1

16. mkdir djbuild

17. cd djbuild

18. ../configure --target=i586-pc-msdosdjgpp --prefix=/opt/djgpp --enable-languages="c,c++"

19. edit ./gcc/Makefile, changing this part:

libgcc1-test: libgcc1-test.o native $(GCC_PARTS)
	@echo "Testing libgcc1.  Ignore linker warning messages."
	$(GCC_FOR_TARGET) $(GCC_CFLAGS) libgcc1-test.o -o libgcc1-test \
	  -nostartfiles -nostdlib `$(GCC_FOR_TARGET) --print-libgcc-file-name`

to read:

libgcc1-test: libgcc1-test.o native $(GCC_PARTS)
	@echo "Testing libgcc1.  Ignore linker warning messages."
#	$(GCC_FOR_TARGET) $(GCC_CFLAGS) libgcc1-test.o -o libgcc1-test \
#	  -nostartfiles -nostdlib `$(GCC_FOR_TARGET) --print-libgcc-file-name`
	touch libgcc1-test

(note the #'s)
(recommended by http://www.delorie.com/howto/djgpp/linux-x-djgpp.html)

20. download gcc30s2.zip; unzip to a temp directory and copy [temp-dir]/diffs/gcc/sdbout.c.diff to ~/temp/gcc-3.0.1/gcc

21. cd ~/temp/gcc-3.0.1/gcc

22. patch ./sdbout.c ./sdbout.c.diff

23. cd ~/temp/gcc-3.0.1/libiberty

24. edit getpwd.c, adding #define PATH_MAX 512 to the top.
(got value from djgpp limits.h)

25. mkdir -p ~/temp/gcc-3.0.1/djbuild/i586-pc-msdosdjgpp/libstdc++-v3/include/i586-pc-msdosdjgpp/bits

26. copy ~/temp/gcc-3.0.1/libstdc++-v3/config/os/djgpp/bits/*
to
~/temp/gcc-3.0.1/djbuild/i586-pc-msdosdjgpp/libstdc++-v3/include/i586-pc-msdosdjgpp/bits/

27. chmod ugo-w ~/temp/gcc-3.0.1/djbuild/i586-pc-msdosdjgpp/libstdc++-v3/include/i586-pc-msdosdjgpp/bits/*

28. cd ~/temp/gcc-3.0.1/djbuild

29. make

30. make install

31. cd /opt/djgpp/i586-pc-msdosdjgpp/src/stub

32. gcc -o stubify stubify.c

33. cp stubify /opt/djgpp/bin

34. cp stubify /opt/djgpp/i586-pc-msdosdjgpp/bin

Any thoughts on how to proceed?

Thanks,
Will Robinson

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019