dynamic shared library that includes both C++ and C sources
Keith Bostic
bostic@abyssinian.sleepycat.com
Mon Oct 4 06:08:00 GMT 1999
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 on BSD/OS 4.0, but I've
seen the same problem on both FreeBSD 3.2-STABLE and SUSE Linux
6.X.
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
More information about the Gcc-bugs
mailing list