Date: Wed, 1 Sep 1999 08:17:03 -0700 (PDT) From: bostic@sleepycat.com To: freebsd-gnats-submit@freebsd.org Subject: gnu/13525: gcc fails load against library with both C++ and C modules Message-ID: <19990901151703.B587214E17@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 13525 >Category: gnu >Synopsis: gcc fails load against library with both C++ and C modules >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Sep 1 08:20:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Keith Bostic >Release: FreeBSD 3.2-STABLE >Organization: Sleepycat Software >Environment: Not available. >Description: 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? >How-To-Repeat: 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. >Fix: >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990901151703.B587214E17>