User:Combuster/Frankenstein's MSVC: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
Content added Content deleted
mNo edit summary
m (Added "in progress" tags, grammar fixes in == Preamble ==)
Line 1: Line 1:
{{Rating|2}}
{{Rating|2}}
{{In_Progress}}


= Introduction =
= Introduction =
== Preamble (fancy) / Introduction (normal?) / Hello (casual) ==
== Preamble (fancy) / Introduction (normal?) / Hello (casual) ==
Have you ever dreamt of using Microsoft C/C++ Optiziming Compiler on Linux? Did you have trouble programming in unfamiliar GCC environment?
Have you ever dreamt of using Microsoft C/C++ Optimizing Compiler on Linux? Did you have trouble programming in an unfamiliar GCC environment? This article is the answer to configuring the build environment that you dreamt of; it will solve any problems that you had with GCC!
Here is the answer to configuring the build environment that you dreamt; that will solve any problems that you had with GCC!


== Solution ==
== Solution ==

Revision as of 20:33, 29 July 2010

Difficulty level

Medium
This page is a work in progress.
This page may thus be incomplete. Its content may be changed in the near future.

Introduction

Preamble (fancy) / Introduction (normal?) / Hello (casual)

Have you ever dreamt of using Microsoft C/C++ Optimizing Compiler on Linux? Did you have trouble programming in an unfamiliar GCC environment? This article is the answer to configuring the build environment that you dreamt of; it will solve any problems that you had with GCC!

Solution

There are many ways that you can utilise Visual C++ (Microsoft C/C++ Optimizing Compiler) for an OS development. First, you can simply use Visual C++ on Windows with all Microsoft tools. But, this has a lot of problems. First, Microsoft Linker (link.exe) does not support the link script (I mean the linker script that can be used to model your executable file). Since it is critical that 'YOU' model the final executable file of a kernel or OS image, it is almost impossible to write an OS with Microsoft Linker. Here are the solutions for this on Windows: 1. use GCC+Binutils on Cygwin (ditch VC++), or only use Binutils LD with COFF support to link CL.exe output COFF object files). In fact, the second solution (using Bintuils LD under Cygwin to link COFF object files) is one of the best solutions. However, why not try 'VICE VERSA'?; using CL.exe on Linux, and LD to link the output files. I tried every method that I mentioned above and decided that the last one (using CL.exe on Linux) was the best because it was easier to work on kernel development in Linux environment mainly due to its interface style. Think about this; there is no native support for Virtual Floppy Drive in Windows, Microsoft Linker has somewhat restricted functions, and it is impossible to 'customise' Windows. Personally, it was much easier to work in Linux environment than using Cygwin on Windows.

Configuring environment

Prerequisites

  • Windows system - In order to legally do this, you must have a valid Windows licence (this is due to the 'winetricks' procedure.).
    • Visual Studio (C++) - You need to have Visual Studio installed on your Windows system in order to get the compilers from it. If you don't, you can download Express version from Microsoft website.
  • Linux system (or any compatible systems)
    • X-Window - recommended to have this in order to do 'winetricks'.
    • Basic build environment - used to build Binutils.
    • Wine - used to run Microsoft C/C++ Optimizing Compiler on Linux.

Running Microsoft C/C++ Optimizing Compiler on Linux

  1. Go to your Visual C++ binary directory (ex: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin).
  2. Copy all files into your Linux system (use FTP, SFTP, SMB or any equivalent file transfer methods). Tip: make sure to copy 1033 directory. 1033\clui.dll is used by cl.exe and must exist under (cl.exe Directory Path)\1033. If you are only willing to build i386 program, only copy the files in the binary directory and 1033 directory (you don't need to copy the files under x86_amd64, x86_ia64).
  3. Copy mspdb**.dll from your Windows system to Wine system32 directory (ex: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\mspdb80.dll to ~/.wine/drive_c/windows/system32).
  4. Try to run cl.exe and see if it works (ex: wine cl.exe). If it displays an error message (that is caused by a runtime DLL), do the following steps, otherwise skip to step 4.
    1. cd ~/.wine
    2. wget http://www.kegel.com/wine/winetricks (or any equivalent methods to download the specified file from the web.)
    3. sh winetricks corefonts vcrun6 vcrun2003 vcrun2005 vcrun2008 (install the runtime version that you need. see http://wiki.winehq.org/winetricks for more information.) Tip: make sure that you run this command under X-Window. Otherwise, you will not see the EULA user acceptance window.
    4. Go back to the directory where you saved the Microsoft C/C++ Optimizing Compiler executable files and try running cl.exe. It should work in this time. If it does not, make sure that you copied all required files from Visual Studio directory and 'winetricks' ran without any error messages.
  5. Enjoy

Configuring Binutils for Microsoft C/C++ Optimizing Compiler

  1. LOREM IPSUM DOLOR SIT AMET

FAQ

1. I've never heard of Microsoft C/C++ Optimizing Compiler. What is it?

That's not true. You've always been hearing about it. It's the compiler that Visual C++ IDE uses as default (comes with Visual C++).

2. Why would you use Microsoft C/C++ Optimizing Compiler on Linux while there is GCC?

It's mainly because of one's preference. GCC has its own style, and so does Microsoft C/C++ Optimizing Compiler. If you like MSCOC, you might want to use it on Linux as well as you do in Windows. In addition, if you have been using MSCOC for years, it is human nature that one prefers to use MSCOC than GCC.