From owner-freebsd-questions@FreeBSD.ORG Sun Feb 7 01:27:58 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2BE1106566B for ; Sun, 7 Feb 2010 01:27:58 +0000 (UTC) (envelope-from pieter@degoeje.nl) Received: from mx.utwente.nl (mx2.utsp.utwente.nl [130.89.2.13]) by mx1.freebsd.org (Postfix) with ESMTP id 497008FC16 for ; Sun, 7 Feb 2010 01:27:57 +0000 (UTC) Received: from nox.student.utwente.nl (nox.student.utwente.nl [130.89.165.91]) by mx.utwente.nl (8.12.10/SuSE Linux 0.7) with ESMTP id o171Rmo2030196; Sun, 7 Feb 2010 02:27:48 +0100 From: Pieter de Goeje To: freebsd-questions@freebsd.org Date: Sun, 7 Feb 2010 02:27:47 +0100 User-Agent: KMail/1.9.10 References: <7B9397B189EB6E46A5EE7B4C8A4BB7CB383B24D6@MBX03.exg5.exghost.com> In-Reply-To: <7B9397B189EB6E46A5EE7B4C8A4BB7CB383B24D6@MBX03.exg5.exghost.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201002070227.48003.pieter@degoeje.nl> X-UTwente-MailScanner-Information: Scanned by MailScanner. Contact icts.servicedesk@utwente.nl for more information. X-UTwente-MailScanner: Found to be clean X-UTwente-MailScanner-From: pieter@degoeje.nl X-Spam-Status: No Cc: Peter Steele Subject: Re: What is easiest way to build a BSD 8 binary on a BSD 7 box? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Feb 2010 01:27:58 -0000 On Saturday 06 February 2010 20:22:13 Peter Steele wrote: > I have a BSD 7 system with the full BSD 8 sources loaded on it, and we use > this box to build our custom BSD 8 kernel and tools. We do not install the > custom code on the BSD 7 box but simply collect the artifacts as a basis > for our custom BSD 8 image. I have a standalone tool that has previously > been built on this same BSD 7 system, but it just uses gcc and links > against the normal BSD 7 libraries that are located on this box. > > When we run this tool on a BSD 7 box it works fine. However, we've > discovered one function it performs doesn't work properly. It uses kvm_read > to collect network statistics and apparently applications that use this > function have to be linked against the libraries of the actual target OS. > One easy solution of course is to build our tool on a BSD 8 box, and in the > long run we'll likely go that route as we move away from BSD 7. Right now > though our build server is BSD 7 and we need to build this tool against BSD > 8 libraries. This obviously can be done since "make world" does exactly > that-it builds everything against 8.0 objects even if the build is done on > a BSD 7 box. > > Without dissecting the magic going on in "make world", can any explain how > I could do the same thing with my standalone tool? Specifically, build it > on a BSD 7 box but link it against BSD 8 libraries. The easiest way would probably be the following. # SOMEDIR=/path/to/fbsd8buildenv # mkdir -p ${SOMEDIR} # cd /path/to/FreeBSD-8.0/src # make buildworld # make installworld DESTDIR=${SOMEDIR} Then adding --sysroot=${SOMEDIR} to all invocations of gcc/ld and/or liberal use of -I and -L gcc options should do the trick. For example: # export CFLAGS="-I${SOMEDIR}/usr/include -L${SOMEDIR}/lib -L${SOMEDIR}/usr/lib # make Regards, Pieter de Goeje