Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HELP: Calling C++ library functions from C

0 views
Skip to first unread message

Paul M. Dubuc

unread,
Jun 23, 1999, 3:00:00 AM6/23/99
to
I'm trying to compile a shared object (.so) library (under SCO
UnixWare 2.1.3)
originally written in ANSI C with the C++ compiler. We are trying to do
some
internal enhancements of the library code using C++ (the external
interface
will remain ANSI C). I've made all the necessary code changes so that
it
compiles with either C and C++. The problem comes when I try to link an

application compiled with C against the .so compiled in C++. I get the
following
undefined symbol:

__process_needed_destructions

When the application is compiled with C++ it links fine against the
.so, but since this this library has a legacy, we don't want to require
all our users to recompile their applications in C++ just to use our
API.
I think this symbol is related to the issue of static initialization

and destruction in C++. C++ compilers insert functions in the main()
routine to take care of initialization/construction and destruction of
global and static objects. C compilers don't do this, of course, hence
the undefined function.
I've read (see pp. 273-5 of Scott Meyers' "More Effective C++")
that there might be other ways of accomplishing global
static construction and destruction without requiring main() to be
compiled with C++. Is there a way to do this with the UnixWare 2.1.3
C++ compiler? I hope so. The enhancements I want to make are
going to be a lot harder (and less fun) if I have to do them in C.

I really hope someone here can help me with this. Please reply
by e-mail if possible.

Thanks,

Paul Dubuc

--
Paul M. Dubuc (614) 860-7836 (voice & fax)
Lucent Technologies du...@lucent.com
Rm. 3s319 http://waterworks.cb.lucent.com/pmd/
6200 E. Broad St.
Columbus, OH 43213-1569

J. L. Schilling

unread,
Jun 25, 1999, 3:00:00 AM6/25/99
to
Paul M. Dubuc (du...@lucent.com) wrote:
: I'm trying to compile a shared object (.so) library (under SCO

: UnixWare 2.1.3)
: originally written in ANSI C with the C++ compiler. We are trying to do
: some
: internal enhancements of the library code using C++ (the external
: interface
: will remain ANSI C). I've made all the necessary code changes so that
: it
: compiles with either C and C++. The problem comes when I try to link an

: application compiled with C against the .so compiled in C++. I get the
: following

: undefined symbol: [...]

To do this in the UW 2.1.3 SDK, you need to link (not compile) the
C main with CC rather than cc.

If you are using the UDK, this works even if the main is linked with cc.

--
Jonathan Schilling SCO, Inc. j...@sco.com

0 new messages