-----BEGIN PGP SIGNED MESSAGE-----
I was reading the various posts on cross compilating stuff. (I want to build *CYGWIN* stuff on Linux. I don't need MINGW32) I can certainly install the MINGW32 .deb package, but that doesn't give me the cygwin stuff that I want. Ironically, if you google for "cygwin cross compiler linux" (including the quotes), you only get Christopher Faylor's post telling everyone that you should google for that :-) http://www.cygwin.com/ml/cygwin/2003-03/msg02047.html for instance says: "Brought over /lib, /usr/lib and /usr/include from my Cygwin machine, put in $HOME/cross/i386-pc-cygwin/lib, ...-cygwin/usr/lib, and ...-cygwin/include respectively..." I'm always disturbed by this. Why should I have to copy stuff from a cygwin machine? Shouldn't I be able to build all of that with my cross compiler? After lots of googling, I came up with: http://www.wxwidgets.org/technote/crosscmp.htm is a better description, but is rather dated (since it talks about egcs...) http://is.rice.edu/~welsh/cross-compiler/Cross-Compiling-bookmarks.html has lots of bookmarks, alas: http://troy.il.fontys.nl/~jasper/linux/cross.html is no more. Try: http://web.archive.org/web/20011104203312/http://troy.il.fontys.nl/~jasper/linux/cross.html Also dated, refers to egcs. http://www.delorie.com/howto/cygwin/cygwin-cross-howto.html is also very dated. I worked with the debian mingw32 with -nostdlib/-nostdinc and -isystem pointed to a copy of the stuff copied from the win32 machine, for awhile. I just now got all the issues sorted out with the cross-build. WHAT I DID. {In the course of this, I think that cygwin copied binutils CVS into the winsup CVS. Maybe I'm crazy. The CVS logs shows a full history, so... But, binutils isn't needed anymore} Pick a directory to build in. In my case /0g/sandboxes 0) download, ./configure, make and install cocom from http://cocom.sourceforge.net/ (They have an RPM, but I didn't find a .deb) This gets you the "shakli" program. It is a program to help create fast parsers. I think it is used for the fs emulation layer. a) extract gcc-4.0.1 b) check out winsup as told on: http://cygwin.com/cvs.html d) cd winsup ln -s ../gcc-4.0.1/fixincludes . ln -s ../gcc-4.0.1/gcc . ln -s ../gcc-4.0.1/libcpp . ln -s ../gcc-4.0.1/libstdc++-v3 . rm -rf winsup/mingw # has CC_FOR_TARGET/CC mixups rm -rf sid # has some problem,and we don't need it rm -rf rda # has dependancy on intl, which # doesn't get built. MAKE SURE THAT "." is not in your PATH. Some symlinks are made by the name "as" which can screw things up. e) cd .. mkdir build cd build ../../winsup/configure --prefix=/myprefix/cross --target=i686-pc-cygwin --without-headers --with-newlib --disable-shared --enable-languages=c,c++ make mkdir -p /myprefix/cross/lib/gcc/i686-pc-cygwin/4.0.1/install-tools/include make install f) cat hello/hello.c #include <stdio.h> main(int argc, char *argv[]) { printf("hello there\n"); } cd hello PATH=/myprefix/cross/bin:$PATH export PATH make CC=i686-pc-cygwin-gcc hello scp hello win2kmachine: ssh win2kmachine ./hello g) build your favorite stuff, e.g: extract libgmp4, mkdir build/gmp4 cd build/gmp4 PATH=/myprefix/cross/bin:$PATH export PATH CC=i686-pc-cygwin-gcc ../../gmp-4.1.2/configure --prefix=/myprefix/cross/i686-pc-cygwin/include --host=i686-pc-cygwin --with-pic (--with-pic gets rid of some issues that I had with the assembly, at a cost of some performance) WHAT I FIXED ============ CC and CC_FOR_TARGET are confused a lot in the winsup makefiles. CC is only when building stuff you need to run on the local machine. The patch is attached against CVS from 2005-08-03. I had an issue with cp-demangle.c. I never resolved it. I don't get it. I later found that it was because I had linked libstdc++ to the gcc-3.4.3 version rather than the gcc-4.0.1 version. I "fixed" it by doing: In winsup/cygwin/Makefile.in, the build of cygwin0.dll (aka ${TEST_DLL_NAME}), has to reference -lcygwin, which hasn't been built/installed yet. (it is in . as libcygwin.a) I actually don't think we should -lcygwin at all. Two possible solutions are: a) -nostdlib -lstdc++ -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc b) -L. I prefer (a), because we shouldn't be referencing it all. I was not able to build mingw, which is why I move it aside in (d). I did not investigate this deeply, since I don't care about native code for the moment. WHAT I DID WRONG ================ The first time, I tried building binutils seperately. This failed when building GCC 3.x. The problem is that the AR_FOR_TARGET macros used in the makefiles for gcc are, it seems expanded a variable number of times in different paths, and the t=/echo $$t stuff got expanded by MAKE rather than by the shell script. I rebuilt again with the ln-s for binutils, and this didn't happen, because one never gets to that part of the condition for AR_FOR_TARGET. So there is still a bug there, but I didn't manage to fix it. - -- ] Michael Richardson Xelerance Corporation, Ottawa, ON | firewalls [ ] mcr @ xelerance.com Now doing IPsec training, see |net architect[ ] http://www.sandelman.ca/mcr/ www.xelerance.com/training/ |device driver[ ] I'm a dad: http://www.sandelman.ca/lrmr/ [ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) Comment: Finger me for keys iQCVAwUBQvMNJoqHRg3pndX9AQFkHQQA2vzcPXB66BFiU4IRYC8KKygUjyb7GsvM yLHb2zNNUAVNLhEvYHf0BndILH4/V0Xls9LtMLuOHV0rk05/OUA3nWFEvWdCMdV+ yvaZc9oiQ7vLTMMqfjiuSy+lhxok0ZDL5TnxM6m6J0/fW1kfxgOA6t3Jq30oIsA3 PlTos2uLws0= =Dy8l -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/