Back to wiki
__General cross-compiler__ A complete cross-compiler can be set up easily. For example: $ cd binutils-2.18 $ ./configure --target=mips-netbsdelf $ make&& make install $ cd ../pcc $ ./configure --target=mips-netbsdelf $ make&& make install The compiler from the above example is called /usr/local/bin/mips-netbsdelf-pcc. Copying the header files from the target machine into /usr/local/mips-netbsdelf/include and the libraries into /usr/local/mips-netbsdelf/lib is sufficient to build binaries. It's possible for multiple cross-compilers to exist on the host system at the same time (which was the motivation for doing this!). __Cross-compiler to Microsoft Windows__ Building a cross-compiler for Windows follows a similar process to the above; however be aware that using pcc to generate '.exe' executables is best described as a 'work in progress' at the present time. Specifically, pcc is unable to compile the support libraries for either itself or the Windows runtime, so the gcc cross-compiler needs to be installed and used for this. Also, pcc cannot currently parse the #pragma's included by "windows.h", which means that you're pretty much limited to compiling console programs. It is hoped that these issues can be resolved and these build instructions are provided to outline the steps needed in creating a cross-compiler, and to assist as a test case for anticipated compiler fixes. You will need header files and libraries for Windows; these files are maintained by the MinGW project. You can find pcc-supported source and binary tarballs of these libraries [on the pcc website](http://pcc.ludd.ltu.se/ftp/pub/win32/) and in addition you will need [binutils](http://ftp.gnu.org/gnu/binutils/). These instructions will create a cross-compiler called '/usr/local/bin/i386-pe-pcc' with all includes and libraries in '/usr/local/i386-pe'. (Root password is required for the installation steps; if you are a 'sudo' user replace *su -c 'make install'* with *sudo make install* in the examples.) - Stage 1: Prerequisites to give five directories named 'binutils', 'mingw32', 'pcc', 'pcc-libs' and 'w32api' (assumes cvs is installed, if not then pcc/pcc-libs are available as [source snapshots](http://pcc.ludd.ltu.se/ftp/pub/pcc-beta/)): mkdir pcc-win32 ; cd pcc-win32 tar -zxf binutils-2.21.tar.gz ; mv binutils-2.21/ binutils tar -zxf mingw-runtime-3.14pcc-src.tar.gz ; mv mingw-runtime-3.14/ mingw32 tar -zxf w32api-3.11pcc-src.tar.gz ; mv w32api-3.11/ w32api cvs -d :pserver:email@example.com:/cvsroot co pcc cvs -d :pserver:firstname.lastname@example.org:/cvsroot co pcc-libs - Stage 2: Build the pcc cross-compiler and necessary tools (assembler/linker etc.) with options set for pcc to look in '/usr/local/i386-pe/include' when compiling as we don't want to use the host system includes in this case: cd binutils ./configure --target=i386-pe make su -c 'make install' cd ../pcc ./configure --target=i386-pe --with-incdir=/usr/local/i386-pe/include/ \ --with-libdir=/usr/local/i386-pe/lib make CC=pcc su -c 'make install' - Stage 3: Build the support libraries. As mentioned, these must currently all be compiled with gcc; change the '/usr/bin/i686-pc-mingw32-gcc' below to the name of your cross-compiler executable. Also, note that 'short name' versions of the binutils have been installed to '/usr/local/i386-pe/bin/', and we need these on $PATH ahead of the host defaults AFTER 'configure' has been run for each build directory. cd ../pcc-libs ; ./configure --target=i386-pe cd ../mingw32 ; ./configure --target=i386-pe --prefix=/usr/local/i386-pe/ cd ../w32api ; ./configure --target=i386-pe --prefix=/usr/local/i386-pe/ export PATH="/usr/local/i386-pe/bin/:$PATH" export CCROSS=/usr/bin/i686-pc-mingw32-gcc cd ../pcc-libs make CC=$CCROSS PCCLIBDIR=/usr/local/i386-pe/lib/ PCCINCDIR=/usr/local/i386-pe/include/ su -c 'make install PCCLIBDIR=/usr/local/i386-pe/lib/ PCCINCDIR=/usr/local/i386-pe/include/' cd ../mingw32 make CC=$CCROSS su -c 'make install' cd ../w32api make CC=$CCROSS su -c 'make install' And that's it! You should now be able to run 'i386-pe-pcc' to compile simple (console) programs, which will invoke only 'i386-pe-as' and 'i386-pe-ld' (you may wish to open a new shell because of your altered $PATH): i386-pe-pcc -o /tmp/helloworld.exe /tmp/hellow.c Be sure to check status of pragma support in pcc on [the bug tracking system](http://pcc.ludd.ltu.se/jira) and changes to the MinGW release files before submitting bugs for this build.
Powered by rcshistory.cgi 0.3