<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> <TITLE>Glibc 2 HOWTO: Compiling C++ programs.</TITLE> <LINK HREF="Glibc2-HOWTO-8.html" REL=next> <LINK HREF="Glibc2-HOWTO-6.html" REL=previous> <LINK HREF="Glibc2-HOWTO.html#toc7" REL=contents> </HEAD> <BODY> <A HREF="Glibc2-HOWTO-8.html">Next</A> <A HREF="Glibc2-HOWTO-6.html">Previous</A> <A HREF="Glibc2-HOWTO.html#toc7">Contents</A> <HR> <H2><A NAME="s7">7. Compiling C++ programs.</A></H2> <P> <!-- glibc!C++ programs, compiling --> <P>Libg++ uses parts of the math library, so is link to libm. Since your existing libg++ will be compiled with your old library, you will have to recompile libg++ with glibc or get a binary copy. The latest source for libg++ along with a binary linked with glibc (for x86) can be found at <A HREF="ftp://ftp.yggdrasil.com/private/hjl/">ftp://ftp.yggdrasil.com/private/hjl/</A>. <P> <H2><A NAME="ss7.1">7.1 Installing libg++ for a test glibc install.</A> </H2> <P> <!-- glibc!libg++, installing!as test library --> If you have installed glibc as a test library, you need to install the files into the directory you installed glibc into (such as <CODE>/usr/i486-linuxglibc2</CODE> for the example in the previous sections). If you are installing from the binary package (which i would recommend, since i never had any luck compiling libg++ this way), you need to extract the files into a temporary directory and move all the <CODE>usr/lib/</CODE> files into the <CODE><install directory>/lib/</CODE> directory, the <CODE>usr/include/</CODE> files into the <CODE><install directory>/include/</CODE> directory (remember to delete your <CODE>include/g++</CODE> link first!), and the <CODE>usr/bin/</CODE> files into the <CODE><install directory>/bin/</CODE> directory. <P> <H2><A NAME="ss7.2">7.2 Installing libg++ for a primary glibc install.</A> </H2> <P> <!-- glibc!libg++, installing!as primary library --> If you have installed glibc as the primary library, you first need to move your old libg++ files into your old libc directory if you still want to be able to compile g++ programs with your old libc. Probably the easiest way to do this is by installing a new copy of the libg++ compiled with libc 5 as in the previous section, and then installing the glibc version normally. <P> <H2><A NAME="ss7.3">7.3 Compiling C++ programs with the non-primary libc.</A> </H2> <P> <!-- glibc!C++ programs, compiling!with non-primary libc --> If you are trying to compile a C++ program with a non-primary libc, you will need to include the g++ include dir, which in the examples above would be <CODE>/usr/i486-linuxglibc2/include/g++</CODE> for a test glibc install or <CODE>/usr/i486-linuxlibc5/include/g++</CODE> for a primary glibc install. This can usually be done by appending the <CODE>$CXXFLAGS</CODE> variable: <BLOCKQUOTE><CODE> <PRE> CXXFLAGS = -nostdinc -I/usr/i486-linuxglibc2/include -I/usr/lib/gcc-lib/i486-linuxglibc2/2.7.2.2/include -I/usr/i486-linuxlibc5/include/g++ -b i486-linuxglibc2 </PRE> </CODE></BLOCKQUOTE> <P> <P> <HR> <A HREF="Glibc2-HOWTO-8.html">Next</A> <A HREF="Glibc2-HOWTO-6.html">Previous</A> <A HREF="Glibc2-HOWTO.html#toc7">Contents</A> </BODY> </HTML>