1<!--$Id: flags.so,v 10.13 2006/10/05 01:06:05 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB Reference Guide: Changing compile or load options</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<a name="2"><!--meow--></a><a name="3"><!--meow--></a> 12<table width="100%"><tr valign=top> 13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Building Berkeley DB for UNIX/POSIX systems</dl></b></td> 14<td align=right><a href="/build_unix/small.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/build_unix/install.html"><img src="/images/next.gif" alt="Next"></a> 15</td></tr></table> 16<p align=center><b>Changing compile or load options</b></p> 17<p>You can specify compiler and/or compile and load time flags by using 18environment variables during Berkeley DB configuration. For 19example, if you want to use a specific compiler, specify the CC 20environment variable before running configure:</p> 21<blockquote><pre>prompt: env CC=gcc /dist/configure</pre></blockquote> 22<p>Using anything other than the native compiler will almost certainly mean 23that you'll want to check the flags specified to the compiler and 24loader, too.</p> 25<p>To specify debugging and optimization options for the C compiler, 26use the CFLAGS environment variable:</p> 27<blockquote><pre>prompt: env CFLAGS=-O2 /dist/configure</pre></blockquote> 28<p>To specify header file search directories and other miscellaneous options 29for the C preprocessor and compiler, use the CPPFLAGS environment variable:</p> 30<blockquote><pre>prompt: env CPPFLAGS=-I/usr/contrib/include /dist/configure</pre></blockquote> 31<p>To specify debugging and optimization options for the C++ compiler, 32use the CXXFLAGS environment variable:</p> 33<blockquote><pre>prompt: env CXXFLAGS=-Woverloaded-virtual /dist/configure</pre></blockquote> 34<p>To specify miscellaneous options or additional library directories for 35the linker, use the LDFLAGS environment variable:</p> 36<blockquote><pre>prompt: env LDFLAGS="-N32 -L/usr/local/lib" /dist/configure</pre></blockquote> 37<p>If you want to specify additional libraries, set the LIBS environment 38variable before running configure. For example, the following would 39specify two additional libraries to load, "posix" and "socket":</p> 40<blockquote><pre>prompt: env LIBS="-lposix -lsocket" /dist/configure</pre></blockquote> 41<p>Make sure that you prepend -L to any library directory names and that you 42prepend -I to any include file directory names! Also, if the arguments 43you specify contain blank or tab characters, be sure to quote them as 44shown previously; that is with single or double quotes around the values 45you are specifying for LIBS.</p> 46<p>The env command, which is available on most systems, simply sets one or 47more environment variables before running a command. If the env command 48is not available to you, you can set the environment variables in your 49shell before running configure. For example, in sh or ksh, you could 50do the following:</p> 51<blockquote><pre>prompt: LIBS="-lposix -lsocket" /dist/configure</pre></blockquote> 52<p>In csh or tcsh, you could do the following:</p> 53<blockquote><pre>prompt: setenv LIBS "-lposix -lsocket" 54prompt: /dist/configure</pre></blockquote> 55<p>See your command shell's manual page for further information.</p> 56<table width="100%"><tr><td><br></td><td align=right><a href="/build_unix/small.html"><img src="/images/prev.gif" alt="Prev"></a><a href="/toc.html"><img src="/images/ref.gif" alt="Ref"></a><a href="/build_unix/install.html"><img src="/images/next.gif" alt="Next"></a> 57</td></tr></table> 58<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 59</body> 60</html> 61