Boost logo

Boost :

From: Michael Stevens (Michael.Stevens_at_[hidden])
Date: 2003-04-29 08:13:09

Dear Boosters,

I've attached a additional Boost Build Toolset description file. It
allows cross compiling using the Visual C++ 7 tools under another system
(Linux etc) that supports Wine.

I find this very useful for regression testing. I can build using GCC
and VC7 directly on my Linux system. Hopefully this will be useful to

    There are two possible way to achieve thi Cross Boost build. Either
to run all of (including bjam) under Wine, OR run as normal natively and run only the needed compiler tools
under wine.

I use the latter method. It requires only the native version of bjam and
does not require a command shell under Wine.

"winevc7-tools-jam" should be placed in the "tools/build" directory of

Visual C++ must first be installed! This best achieved under Windows.
Once installed the existsing Windows partition can be easily mounted
under Linux etc. It is probably equally possible simply to copy the
installed files to some convinient directory.

Wine must be configured so that the Visual C++ tools are in the Wine
path. That is
    wine cl
    wine link
can be executed from a shell without error. The above should show the
command line options of the visual C compile and linker.

The compiler and linker in VC7 requires that 3 additional directories
out of VC7 installation be specifed to the Wine Path. The Wine Path is
set in "~/.wine/config". Inside the [wine]section add to "Path" = the 3
additional directories. For example if under Wine the Windows partition
appears as C: and the English VC7 was installed:

"Path" = "XXXX;C:\\Program Files\\Microsoft Visual Studio
.NET\\Vc7\\bin;C:\\Program Files\\Microsoft Visual Studio
.NET\\Common7\\IDE;C:\\Program Files\\Microsoft Visual Studio
.NET\\Visual Studio .NET Professional - English"

where XXXX is what was used previously.

   The VC tools need to know where to find the appropriate header and
system library files. Boost build can supply these directly, the only
requirement is that the enviroment variable "MSVCDir" to be set.
 The new name for the Build toolset is "winevc7". Combining these two,
gives a single cross compile command line:

    export MSVCDir="/windows/C/Program Files/Microsoft Visual Studio
.NET/Vc7"; bjam -sTOOLS=winevc7

   The MSVCDir directory specified is always accessed through Wine,
therefore it can be in either DOS or Posix format.
   It may also be possible to setup the INCLUDE and LIB enviroment
variables directly in Wine. The above method seems the most flexible

The same should also work for VC6 by simpily creating a copy of the
"winevc7-tools.jam" and changing the "extends-toolset vc7" to
"extends-toolset msvc". Since I don't have VC6 I have not tested this.

While working on this, a couple of relevant matters have arrisen:

1. The system should be ported to Boost build v2. The following points
may not be relavant in this case.

2. The existing "vc7-tools-jam" file will not link executables if
MSVCDir is used to locate the library files. This is because under VC7
all the system libraries (kernel32.lib etc) live in the PlatformSDK
sub-directory. In my toolset extension I have used
# Ensure PlatformSDK libraries are in library path
flags winevc7 STDLIBPATH : $(MSVCDir)$(SLASH)PlatformSDK$(SLASH)lib ;
maybe this should be added to the existing "vc7-tools.jam"

3. The build output is placed in the "winevc7" directory. The results
are however identical to using the VC7 tools under Windows. Therefore it
would be better to place build output into "vc7". I have not found a
way to convince Boost build not to use a new name. Any suggestions?

4. "boost-base.jam" and "allyourbase.jam" were not designed for cross
compiling! They use the system under which bjam is running to determine
the names of output files and toolset functions. A clearer distiction
needs to be made between the requirements of the native system (creating
build directories etc) and the requirements of the toolset (DLL names
etc). However the existing system is sufficiently flexible that it can
be easily overidden in the case of cross compiling.

All the best,
    Michael Stevens

# Boost Build Toolset description
# Cross-compile Microsoft Visual C++ under Wine

# (C) Copyright Michael Stevens 2003. Permission to copy, use,
# modify, sell and distribute this software is granted provided this
# copyright notice appears in all copies. This software is provided
# "as is" without express or implied warranty, and with no claim as
# to its suitability for any purpose.

extends-toolset vc7 ;

# Cross-compile tools running on Unix compiling with MSVC.
# Requires we overide setting from "allyourbase.jam"
  SLASH = "/" ;
  SPLITPATH = ";" ;
  SUFLIB = .lib ;
  SUFOBJ = .obj ;
  SUFEXE = .exe ;
  SUFDLL = .dll .lib ;
  gLINK_VARIABLE(.dll) = ; # dlls are NOT linked to directly
  gLINK_VARIABLE(.lib) = NEEDLIBS ; # instead, users link to import libs
  PREDLL = "" ;
  NOARSCAN = true ;
  RANLIB = ;

# Overide compiler and linker names
VC_COMPILER = wine -- cl ;
VC_LINKER = wine -- link ;

# Ensure PlatformSDK libraries are in library path
flags winevc7 STDLIBPATH : $(MSVCDir)$(SLASH)PlatformSDK$(SLASH)lib ;

#### Link ####

actions together vc-Link
    $(VC_LINKER) /nologo $(NOINCREMENTAL) $(LINKFLAGS) $(PDB_LINKFLAG)"$(VC_PDB_FILE)" /out:"$(<[1])" /IMPLIB:"$(<[2])" /LIBPATH:"$(LIBPATH)" /LIBPATH:"$(STDLIBPATH)" "$(FINDLIBS:S=.lib)" @"$(>)"

#### Cc #####

actions vc-Cc
    $(VC_COMPILER) /Zm800 -nologo -c -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) -I"$(HDRS)" -I"$(STDHDRS)" $(PDB_CFLAG)"$(VC_PDB_FILE)" -Fo"$(<)" "$(>)"

#### C++ ####
actions vc-C++
    $(VC_COMPILER) /Zm800 -nologo -GX -c -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I"$(STDHDRS)" $(PDB_CFLAG)"$(VC_PDB_FILE)" -Fo"$(<)" -Tp"$(>)"

#### Archive ####

actions updated together piecemeal vc-Archive
    if test -a "$(<)"; then set _$(<:B)_="$(<)"; fi
    $(VC_LINKER) /lib $(ARFLAGS) $(PDB_LINKFLAG)"$(VC_PDB_FILE)" /out:"$(<)" ${_$(<:B)_} @"$(>)"

Boost list run by bdawes at, gregod at, cpdaniel at, john at