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

Content deleted Content added
m 'REAL' Final edit. Please correct any grammar mistakes you find.
m Bot: Replace deprecated source tag with syntaxhighlight
 
(11 intermediate revisions by 7 users not shown)
Line 1:
{{Rating|2Lovecraftian}}
 
Salvaged black magic rituals nobody seems to have tried in three years. Needs some cleanup; use at your own risk.
 
= Introduction =
 
== Preamble ==
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!
 
== SolutionConfiguration ==
There are many ways that you can utilise Visual C++ (Microsoft C/C++ Optimizing Compiler) for an OS development. FirstFirstly, you cancould simply use Visual C++ on Windows with all Microsoft's tools. But, this hasposes a lot of problems. First,For example: Microsoft Linker (link.exe) does not support the link script (I mean the linker script that can be used to model your executable file)scripts. Since it ismay be critical that you can 'YOUmodel' 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 onmay Windows:pose 1.a use GCC+Binutils on Cygwin (ditch VC++), or only use Binutils LD with COFF support to link CLproblem.exe outputThe COFF object files). In fact, the second solution (using Bintuils LD under Cygwin to link COFF object files) is one of the bestavailable solutions. However, whyare not trytoo '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 developmentgreat 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.number:
# Use GCC and Binutils on Cygwin (don't use VC++ at all).
# Use Binutils with COFF support to link COFF object files created by '''cl.exe''' (ditch VC++ linker).
 
It's the second solution that is interesting. You may ask "why not try it the other way around?", but that would remove the benefit of having linker scripts, although it would offer you GCC's 'style'. If you were aiming for the latter, then it may be best for you to just build a [[GCC_Cross-Compiler|GCC cross-compiler]].
 
= 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 StudioC++ installed on your Windows system in order to get the compilers from it. If you don't, you can download an Express version from the Microsoft website.
 
* Linux system (or any other compatible systemssystem)
** 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.
 
Last but not least, having an X Window system on your Linux box is recommended to make your life easier while doing the 'winetricks' procedure, but not required. You may also want to check the [http://appdb.winehq.org/ Wine Database] to see what versions of Wine run which versions of the compiler.
 
== Running Microsoft C/C++ Optimizing Compiler on Linux ==
# Go to your Visual C++ binary directory (ex: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin).
# 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).
# Copy mspdb**.dll from your WindowsVisual systemStudio Common7 directory to Wine system32 directory (ex: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\mspdb80.dll to ~/.wine/drive_c/windows/system32).
# 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.
## cd ~/.wine
Line 41 ⟶ 48:
----
Test.cpp
<syntaxhighlight lang="cpp">
char *VideoMemory = (char *)0xB8000;
extern "C" void Main()
{
const char *HelloWorldMessage[] = "Hello World!";
 
}
while (*HelloWorldMessage != '\0')
VideoMemory++ = HelloWorldMessage++;
}
</syntaxhighlight>
----
TestLS.ld
Line 75 ⟶ 87:
 
= FAQ =
1.=== I've never heard of the Microsoft C/C++ Optimizing Compiler. What is it? ===
That's not true. You've always been hearing about it. It's the compiler that the Visual C++ IDE uses as default (comes with Visualthe C++ component of Visual Studio).
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.
 
=== Why use it on Linux when there is GCC to do the job? ===
[[Category:Tutorials]]
It's mainly because of one's preference. GCC has its own style, and so does Microsoft C/C++ Optimizing Compiler. If you like MSCOCit, you might want to use it on Linux as well as you do in Windows. In addition, if you have been using MSCOCit for years, it's isnot humanstrange natureto thathave onea preferspreference toover use MSCOC than GCCanother.
[[Category:Tools]]