|
Boost Users : |
Subject: Re: [Boost-users] building boost libraries for cross-compiled project
From: Grant Erickson (gerickson_at_[hidden])
Date: 2009-07-13 00:52:35
On 7/12/09 10:31 AM, Steve Drake wrote:
> I am trying to use boost (specifically the regex part) in a cross-compiled
> environment. The target is a single board computer running Linux on ARM. My
> development computer is a Windows 2000 machine.
>
> The cross compiler is a GNU C++ compiler that I got from the SBC vendor. It
> is located here:
>
>
> c:\TechnologicToolchain\devel-tools\crosstool-cygwin\bin\arm-unknown-linux-g
> nu-g++.exe
>
> When I build my ARM application program, by PATH on the PC is set to this:
>
> c:\TechnologicToolchain\devel-tools\crosstool-win\bin; \
> c:\TechnologicToolchain\devel-tools\crosstool-cygwin\bin; \
> c:\TechnologicToolchain\devel-tools\cygwin
>
> How do I build the boost libraries on my development PC so I can link them
> with my cross-compiled application code and run them on the ARM target? I am
> unfamiliar with bjam so I am having trouble figuring out how to configure it
> to use a specific compiler executable.
>
> Thanks in advance for any suggestions.
Steve:
I employ a "shim" makefile for this task. It looks something akin to the
following for the 1_35_0 vintage Boost:
include pre.mak
PackageName := boost
PackageExtension := tar.gz
PackageSeparator := _
PackagePatchArgs := -p1
PackageArchive := $(PackageName).$(PackageExtension)
PackageSourceDir :=
$(PackageName)$(PackageSeparator)$(PackageVersion)/
BoostToolset = $(ToolProduct)
# We don't want versioned headers and libraries, so specify the
# 'system' layout. Also, we do not want all the various combinations
# of shared/static, release/debug, stripped/unstripped and
# non-threaded/threaded libraries, so just specify 'minimal'.
BoostJamConfig = "--layout=system --build-type=minimal"
# The Boost libraries we want (e.g filesystem, threads, etc.). At this
# point, just the filesystem library.
BoostLibraries = filesystem
BoostLibrariesList = $(subst $(SPACE),$(COMMA),$(strip
$(BoostLibraries)))
BoostConfigure = $(call GenerateBuildPaths,configure)
BoostMakefile = $(call GenerateBuildPaths,Makefile)
BoostUserConfig = $(call GenerateBuildPaths,user-config.jam)
CleanDirectories += $(PackageSourceDir) \
$(BuildDirectory) \
$(ResultDirectory)
all: stage
# Generate the package license contents.
$(PackageSourceDir)/LICENSE_1_0.txt: source
$(PackageLicenseFile): $(PackageSourceDir)/LICENSE_1_0.txt
$(Verbose)cat $< > $@
# Extract the source from the archive and apply patches, if any.
$(PackageSourceDir): $(PackageArchive) $(PackagePatchPaths)
$(expand-and-patch-package)
# Prepare the sources.
.PHONY: source
source: | $(PackageSourceDir)
# Patch the sources, if necessary.
.PHONY: patch
patch: source
# Generate the package build makefile.
$(BoostConfigure): | $(PackageSourceDir) $(BuildDirectory)
$(Verbose)lndir -silent $(CURDIR)/$(PackageSourceDir)
$(BuildDirectory)
# Generate the build-specific makefile and user configuration. We have
# to post-process the generated user configuration since Boost's
# build system--at present--appears to have no other way to override the
# actual C++ compiler executable used (see
# http://goodliffe.blogspot.com/2008/05/ cross-compiling-boost.html).
$(BoostMakefile) $(BoostUserConfig): $(BoostConfigure)
$(Verbose)cd $(BuildDirectory) && \
configure \
--prefix=$(ResultDirectory) \
--with-toolset=$(BoostToolset) \
--without-icu \
--with-libraries=$(BoostLibrariesList)
$(Verbose)$(SED) -e
"s,^\(using\)[[:space:]]\+\($(BoostToolset)\)[[:space:]]\+;,\1 \2 : : $(CXX)
;,g" \
< $(BoostUserConfig) > $(BoostUserConfig).N
$(Verbose)mv -f $(BoostUserConfig) $(BoostUserConfig).O
$(Verbose)mv -f $(BoostUserConfig).N $(BoostUserConfig)
# Configure the source for building.
.PHONY: configure
configure: source $(BoostUserConfig) $(BoostMakefile)
# Build the source.
.PHONY: build
build: configure
$(Verbose)$(MAKE) -C $(BuildDirectory) \
BJAM_CONFIG=$(BoostJamConfig) \
all
# Stage the build to a temporary installation area.
.PHONY: stage
stage: build | $(ResultDirectory)
$(Verbose)$(MAKE) -C $(BuildDirectory) \
BJAM_CONFIG=$(BoostJamConfig) \
install
clean:
$(Verbose)$(RM) $(RMFLAGS) -r $(PackageSourceDir)
$(Verbose)$(RM) $(RMFLAGS) -r $(BuildDirectory)
$(Verbose)$(RM) $(RMFLAGS) -r $(ResultDirectory)
include post.mak
Clearly, there's a lot of filling-in-the-blanks to do and things have
changed slightly for 1_39_0; however, that should get you started.
Regards,
Grant
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net