Go to the first, previous, next, last section, table of contents.


10. Using libtool with other languages

Libtool was first implemented in order to add support for writing shared libraries in the C language. However, over time, libtool is being integrated with other languages, so that programmers are free to reap the benefits of shared libraries in their favorite programming language.

This chapter describes how libtool interacts with other languages, and what special considerations you need to make if you do not use C.

10.1 Writing libraries for C++

Creating libraries of C++ code is a fairly straightforward process, and differs from C code in only two ways:

  1. Because of name mangling, C++ libraries are only usable by the C++ compiler that created them. This decision was made by the designers of C++ in order to protect users from conflicting implementations of features such as constructors, exception handling, and RTTI.
  2. On some systems, notably SunOS 4, the dynamic linker does not call non-constant initializers. This can lead to hard-to-pinpoint bugs in your library. GCC 2.7 and later versions work around this problem, but previous versions and other compilers do not.

This second issue is complex. Basically, you should avoid any global or static variable initializations that would cause an "initializer element is not constant" error if you compiled them with a standard C compiler.

There are other ways of working around this problem, but they are beyond the scope of this manual.


Go to the first, previous, next, last section, table of contents.