This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc fails load against shared/dynamic library with both C and C++ modules
- To: help-gcc at gnu dot org
- Subject: gcc fails load against shared/dynamic library with both C and C++ modules
- From: Sleepycat Software <db at abyssinian dot sleepycat dot com>
- Date: Tue, 31 Aug 1999 13:04:30 -0400 (EDT)
I'm having trouble with gcc and a dynamic shared library that
includes both C++ and C sources.
I'm using gcc 2.7.2.1 with gld 2.8.1.
I've seen this problem on BSD/OS 4.0 and FreeBSD 3.2-STABLE.
Here are the steps:
1. Build a dynamic shared library that contains both C++ and
C sources. (The C++ modules are a thin API on top of the
C sources -- they call the C modules, but C modules never
call or reference symbols in the C++ modules.)
2. Build a C-source program and use gcc to link against the
library. Errors appear, such as:
abyssinian:build_local {312} cc -g -I. -Wall -W t.c .libs/libdb-3.0.so
t.c: In function `main':
.libs/libdb-3.0.so: undefined reference to `ostream::operator<<(char const *)'
.libs/libdb-3.0.so: undefined reference to `terminate(void)'
3. Confirm that those symbols don't appear in any C modules:
abyssinian:build_local {313} nm -o *.lo | egrep terminate
cxx_app.lo: U terminate__Fv
cxx_except.lo: U terminate__Fv
cxx_lock.lo: U terminate__Fv
cxx_log.lo: U terminate__Fv
cxx_mpool.lo: U terminate__Fv
cxx_table.lo: U terminate__Fv
cxx_txn.lo: U terminate__Fv
4. Note, you can build the source file correctly if you use C++:
abyssinian:build_local {315} g++ -g -I. -Wall -W t.c .libs/libdb-3.0.so
works.
Does anybody understand what the problem is, here?
Are there any suggested workarounds? Is it a bad idea to include
both C++ and C modules in the same library?
I would appreciate getting any replies by email.
Thank you!
--keith
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Keith Bostic
Sleepycat Software Inc. db@sleepycat.com
394 E. Riding Dr. +1-978-287-4781
Carlisle, MA 01741-1601 http://www.sleepycat.com