Microsoft C, C++, C# Compiler for Windows OS

Get a Free and Legal Copy of Microsoft Compiler to develop and test your programs for Windows without quitting Linux.

@ http://who.is.free.fr/wiki/index.php?MSVC

Next goal is to make it fully usable with GNUmake thus by providing scripts that translate gnu standard command lines to Dos ones ... feel free to contact me if interessed.
1/ GET IT

The Compiler itself is free (not Libre but it cost nothing) and fully usable under Linux w/ wine

get Microsoft Visual Tool Kit : (free version)

http://msdn.microsoft.com/visualc/vctoolkit2003/

 ed2k://|file|VCToolkitSetup.exe|32952488|c534888fa7605403dcb183d2d15282d1|

Then you have compiler/linker (cl.exe) libc and standard includes.

 #rzr@nrv:lib/$ ls /home/rzr/mnt/msvc2003/bin/
 c1.dll    c2.dll  cl.exe.config  link.exe         msobj71.dll  msvcp71.dll
 c1xx.dll  cl.exe  dbghelp.dll    link.exe.config  mspdb71.dll  msvcr71.dll

 #rzr@nrv:lib/$ ls /home/rzr/mnt/msvc2003/lib/
 kernel32.lib  libcd.lib  libcmt.lib  libcpd.lib  libcpmt.lib  oldnames.lib
 libc.lib      libcd.pdb  libcp.lib   libcpd.pdb  mscoree.lib

Platform SDK is provided also (see further)

Missing files and workaround :

    * nmake / use GNUmake should be possible
    * Windows Mfc OpenGL & DirectX libs ? 

2/ Msvc on Linux

Unpack the archive (on Windows )

 mv "Microsoft Visual C++ Toolkit 2003" /mnt/c/opt/msvc2003
 ln /mnt/c/opt/msvc2003 ${HOME}/mnt/msvc2003

then you can manage with some environement setting (to put in a script, ask me for it)

 export MSVC_DIR_GNU="${HOME}/mnt/msvc2003/"
 export MSVC_DIR_DOS="Y:\\mnt\\msvc2003\\"
 export PATH="${MSVC_DIR_GNU}/bin:${PATH}"
 export INCLUDE="${MSVC_DIR_DOS}include"
 export LIB="${MSVC_DIR_DOS}lib"
 export WINEDLLPATH="${DLL_DIR_GNU}:${MSVC_DIR_GNU}bin:${WINEDLLPATH}"
 alias cl="${WINE} ${WINE_OPTS} ${MSVC_DIR_GNU}bin/CL.EXE"
 ...
 cl main.c && wine main.exe # et voila :)

Well to avoid to loose time feel free to improove my wrapper script : http://rzr.online.fr/docs/contribs/bin/cc-msvc.sh (works also w/ vc98)
3/ COMPILE & TEST Windows applications on Linux with Microsoft tools for Free

 #rzr@nrv:cproject/$ cat cmain.c

 #include 
 #include 
 int main(int argc, char* argv[]) {
 #ifdef _MSC_VER
   printf("_MSC_VER=%d\n",_MSC_VER);
 #endif
   return ( EXIT_SUCCESS);
 }

 #rzr@nrv:cproject/$ ~/bin/cc-msvc.sh cl cmain.c
 # wine /home/rzr/mnt/msvc2003/bin/CL.EXE cmain.c
 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3052 for 80x86
 Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

 cmain.c
 Microsoft (R) Incremental Linker Version 7.10.3052
 Copyright (C) Microsoft Corporation.  All rights reserved.

 /out:cmain.exe
 cmain.obj

 #rzr@nrv:cproject/$ cmain.exe
 _MSC_VER=1310

4/ PLATFORMSDK & USING WINAPI

AS said on : http://www.winprog.org/tutorial/msvc.html

Since this is the .NET SDK, it doesn't come with the headers and libraries required for Win32 API development, as these are part of the Platform SDK. Lo and behold, the Platform SDK is free as well. You only need the Core SDK, but feel free to download the other components as you desire.

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/downlevel.htm

The platform SDK can't be easily got to because it uses ActiveX controls.

Here are some direct links:

 http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.bat
 http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/Extract.exe
 http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.1.cab
 http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.*.cab
 http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.13.cab

 ed2k://|file|PSDK-FULL.1.cab|26221140|18832004fd27bb12a12144ab68cd32ca|
 ed2k://|file|PSDK-FULL.2.cab|26221140|cc356f4cfb2fc3628efb69f3ba890f8b|

 ed2k://|file|PSDK-FULL.13.cab|24343136|e64ef6ab33906f68cd3dd8022746bae8|
 ed2k://|file|PSDK-FULL.bat|416|e68abfd97ea840d0841c21a6eee5540a|

note that there are 13 files (of 25Mb each) : PSDK-FULL.1.cab to PSDK-FULL.13.cab, you'll need them all and the two files, PSDK-FULL.bat and Extract.exe in the same directory.

thx baldurk @ http://irc.freenode.net/#winehq
5/ TODO AND GOING FURTHER

    * how to "emulate" gcc command lines ? 

is there a script that translate -I... to /I... etc ? then we can use the full GNU suite and w/ msvs

    * wrap autoconf scripts 

    * I can use nmake from shell (bash) , but no along GNUmake 

 $ cat GNUmakefile
 #NMAKE=${HOME}/bin/nmake.bat # stupid ^M
 NMAKE=${HOME}/bin/nmake.sh

 nmake: ${PROJECT}.mak
	${NMAKE} /f $<

it seems that gmake happend some ^M to the comandline

 NMAKE : fatal error U1065: invalid option '-'^M

MISC TIPS
CONSOLE

How to enable disable console ( go to link options )

 /subsystem:windows
 /subsystem:console

Or put this in your main.cpp

 #pragma comment(linker,"/ENTRY:WinMainCRTStartup")
 #pragma comment(linker,"/SUBSYSTEM:CONSOLE")

FILES

Semi Useless files : .opt .ncb ...

http://filext.com/detaillist.php?extdetail=PDB

A program database (PDB) file holds debugging and project state information that allows incremental linking of a Debug configuration of your program.
SYMBOLS

The following are keywords in Microsoft C and C++. You can't use any C keywords in a C++ program.

Names with leading underscores are Microsoft extensions.

C Language Keywords:

 unsigned signed
 short float char int double long

 void enum union typedef struct sizeof

 if else
 while do for
 switch case default
 break  goto continue
 return

 static const extern volatile register

 asm 	pascal __fortran
 fastcall 	self  auto segment  based __segname
 cdecl 	huge inline interrupt loadds near
 export far 	__saveregs

C++ Language Keywords:

 this class virtual friend private protected public
 throw try catch
 new delete
 operator  inline
 multiple_inheritance single_inheritance __virtual_inheritance

The following are not keywords, but they have special meaning in Microsoft C++:

 main
 argc argv envp
 _setenvp _set_new_handler  __emit _setargv

 #ifdef _MSC_VER  // will detect if you're using msvc ++
 #endif

MFC

Is there any free implementation of MFC ? the wine project may did

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cwnd.asp
MISC

dll : libtool for msvc ? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dynamic_link_library_entry_point_function.asp

Emacs w/ msvc http://www.gnu.org/software/emacs/windows/faq10.html http://www.dotemacs.de/dotfiles/DavidJolley.emacs.html
LINKS

http://who.is.free.fr/wiki/index.php?MSVC

http://appdb.winehq.com/appview.php?appId=53&versionId=31

www.Philippe.COVAL.online.FR
Last modified: Mon Jul 12 13:05:45 CEST 2004