My OS MinGW cross-compiler

I’m still testing out a few options of cross-compilers. This time I’ve built a MinGW cross-compiler for i786 ELF format binaries. As I’ve been pointed out – MinGW does not have any dependencies on external libraries (like Cygwin) and it does not have problems with DOS paths (like Cygwin, which I could not force to work in Eclipse CDT).

Prerequisites

You’ll need the following software:

  1. MinGW
  2. MPFR, GMP and MPC libraries
  3. Latest release of Binutils source
  4. Latest release of GCC source

Installing MinGW and libraries

MinGW installation is straight forward, also you’ll need to install:

  • C Compiler
  • C++ Compiler (just in case)
  • MSYS Basic System
  • and MinGW Developer Toolkit

After you’re done with that, it’s good to add MinGW directories to PATH, so that you can use MinGW tools from Command Prompt. If you install MinGW to it’s default location, then these are the paths you are looking for:

  • C:\MinGW\bin
  • C:\MinGW\msys\1.0\bin

Now fire up cmd.exe and install necessary libraries with this command: mingw-get install gmp mpfr mpc

Compiling the cross-compiler

I found this rather old article on how to do it, but following it through was quite easy. I’ll lead you through with a small step-by-step guide:

  1. Download Binutils and GCC source from the links above, extract them under C:\build-gcc (C:\build-gcc\binutils-x.y.z and C:\build-gcc\gcc-x.y.z, where x.y.z is the version of sources you’ve downloaded);
  2. Download these shell scripts to c:\build-gcc (these shell scripts are a little bit updated versions of the ones in the how-to wiki;
  3. Create a directory C:\cross-gcc;
  4. Now fire up cmd.exe and enter bash shell, simply type bash and hit enter (this should work, because you added MinGW to PATH variable);
  5. In bash type this command first: cd /c/build-gcc/ and ./build_binutils.sh this will start a binutils build process;
  6. After binutills have successfully been installed call ./build_gcc.sh and it will build your gcc cross compiler;
  7. Voila, you’re done! Now you can add the newly created cross-compilers to your PATH to use them with your make scripts in your IDE.

Side note – for me AVG anti-virus somehow did report that “configtest.exe” was carrying a Trojan.Generic26, I just simply ignored that. 🙂

Here’s the same VS2010 project of dummy kernel and bootloader, with MinGW cross-compiler as the main build system

Join the Conversation

3 Comments

    1. sergey mirianovПервым впечатлением было – как вообще в этой штуке можно писать??Шутите или как?Сначала не хватало smart tabs – имено это на 80% заставило написать комент. Затем я нашел smart tabs в настройках – стало легче, но если честно выглядит просто ужасно.Smart tabs – что имеете ввиду? Я под этим понимаю сохранение количества табов в отступе от начала строки при переходе на следующую строку. Если правильно понял, не понимаю, как вы это не нашли сразу и в чем разница с VS (и какой, опять же – не работал с 2008, в 2005ой вроде как все так же, или вы о totmao’s visual assist?)Настроить, что использовать – пробелы или таб – в настройках редактора.Дальше – не возможность скрывать окна, как в студии – я конечно понимаю что это мои проблемы – но смотреть на код как из амбразуры не приятно.F2 скрывает окно с закладками компилятора/дебаггера, вроде как есть шорткат и древо проекта скрывать, ну и как бы любое окно можно масштабировать, закрыть или переместить, включая вкладки, если что не устраивает и нужно расширить амбразуру.Или вам именно без autohide совсем никак?Про разделение предупреждений и ошибок – есть такое. Среда развивается, если вам нужны конкретные фичи быстрее – пишите в форум разработчиков или найдите вечер имплементировать руками и тоже забросить сделанное на форум.Что не так с сообщением об ошибках?Дальше – ужасный красный цвет сообщений об ошибках, я не бывшая школьница чтобы меня ими пугать.Цвет и правда не настраивается. Но знаете ли… не обижайтесь, пожалуйста, но складывается ощущение, что вы не свободную среду разработки пробуете, а выбираете тряпку в тряпичной типа “бутик”. Где мужыцкая брутальность и олдскульно-блокнотно-программистская приспособляемость? После таких оценок становится как-то страшно за следующее поколение беспомощно-эстетских “программистов”, выросших на продукции ms.

Leave a comment

Your email address will not be published.