How to link agains C++-compiled libraries?

From: Arno Hahma <arno_at_azido.pp.utu.fi>
Date: Mon, 22 Jan 2001 13:22:37 +0200

Problem: ld doesn't find objects defined in C++ -compiled shared library.

The problem is apparently, that the mangled names in the library
are different than what ld thinks to look for. This may
be because the software in question defines new C++ classes
based on the ones present in the shared libraries. Then it
tries to link the parent classes from the library, which doesn't
seem to work.

Is there a workaround for this other than linking statically?

Example:

gcc -L/usr/local/qt/lib -rpath /usr/local/qt/lib -o prog <objects> -lqt -lm

Unresolved:
QApplication::QApplication(int &, char **)
QString::QString(char const *)
QFileInfo::QFileInfo(QString const &)
..
..
..

hundreds of lines of complaints.

cxx complains about something different:

ld:
Unresolved:
__4QDirRC7QStringT1ii
__4QDirRC4QDir
__as__4QDirRC4QDir
_$_4QDir
..
..
..

and hundreds of mangled names follow, regardless of, whether the <objects>
were compiled with cxx or gcc.

All symbols are defined libqt.so, if checked with nm.

The compiler/OS versions are:

  Compaq C V6.3-129 (dtk) on Digital UNIX V4.0G (Rev. 1530)
  Compiler Driver V6.3-126 (dtk) cc Driver

  Compaq C++ V6.3-002 for Digital UNIX V4.0G (Rev. 1530)
  Compiler Driver V6.3-002 (cxx) cxx Driver

  gcc 2.95.2

ArNO
    2
Received on Mon Jan 22 2001 - 11:20:22 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:41 NZDT