Libsupcxx: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Solar (talk | contribs)
m /usr/cross -> /usr/local/cross for FHS compatibility
m Add disputed status as documented on the talk page.
Line 1: Line 1:
{{Disputed|Talk:Libsupcxx}}
{{Rating}}
{{Rating}}
Libsupc++ is a support library for g++ that contains functions dealing with run-time type information (RTTI) and exception handling. If you attempt to use either exceptions or RTTI in a C++ kernel you have compiled with a [[GCC Cross-Compiler]] you will also need the libsupc++ library. In general, you should be able to use the one provided as part of a Linux distribution. If, however, you run into problems and need to compile your own, you can follow these steps.
Libsupc++ is a support library for g++ that contains functions dealing with run-time type information (RTTI) and exception handling. If you attempt to use either exceptions or RTTI in a C++ kernel you have compiled with a [[GCC Cross-Compiler]] you will also need the libsupc++ library. In general, you should be able to use the one provided as part of a Linux distribution. If, however, you run into problems and need to compile your own, you can follow these steps.

Revision as of 15:53, 4 November 2013

The factual accuracy of this article is disputed.
Please see the relevant discussion on the talk page.
Difficulty level

Not rated

Libsupc++ is a support library for g++ that contains functions dealing with run-time type information (RTTI) and exception handling. If you attempt to use either exceptions or RTTI in a C++ kernel you have compiled with a GCC Cross-Compiler you will also need the libsupc++ library. In general, you should be able to use the one provided as part of a Linux distribution. If, however, you run into problems and need to compile your own, you can follow these steps.

Create a working GCC Cross-Compiler.

This tutorial assumes it is entitled 'i586-elf-gcc'

Configure gcc

Enter the gcc source directory, run

   ./configure --target=i586-elf --prefix=/usr/local/cross --enable-languages=c,c++ \
       --without-headers --disable-nls
   cd libstdc++-v3

Edit the libstdc++ configure script

Now you need to edit the configure file in the libstdc++-v3 directory. Open it up in the editor of your choice (which preserves unix style line endings) and find a section similar to (it is around line 108,000 in gcc 4.2.1, searching for 'combination' is probably the easiest way to find it):

   { { echo "$as_me:$LINENO: error: No support for this host/target combination." >&5
   echo "$as_me: error: No support for this host/target combination." >&2;}
   { (exit 1); exit 1; }; }
   ;;

and alter the third line so that it reads:

   { { echo "$as_me:$LINENO: error: No support for this host/target combination." >&5
   echo "$as_me: error: No support for this host/target combination." >&2;}
   }
   ;;

Configure and make libsupc++

   CPP=i586-elf-cpp ./configure --host=i586-elf --prefix=/usr/local/cross --disable-hosted-libstdcxx \
       --disable-nls
   cd include
   make
   make install
   cd ../libsupc++
   make
   make install

Usage

Libsupc++ should now be installed into /usr/local/cross/lib. To use it, you will need to add

   -L/usr/local/cross/lib -lsupc++

to your linker command line.

Additional requirements

Libsupc++ also requires that libgcc.a be included in your link as well. This is usually found (if you followed the cross compiler directions) in /usr/local/cross/lib/gcc/i586-elf/<gcc version>. Finally, it has a number of dependencies which your kernel must provide, including (but not limited to) malloc, free, abort and strlen.

Tested on

These steps were tested on g++ 4.2.1 under Cygwin with a cross compiler targeting i586-elf