From: bjb@plaza.ds.adp.com
Subject: Problem linking C++ library with C program
Date: Thu, 11 Jan 2001 18:11:36 GMT [thread overview]
Message-ID: <93kt0e$frh$1@nnrp1.deja.com> (raw)
Hi
I'm trying to create a C++ library that can be used by either a C or
C++ program. The shared header file that the programs see accepts a
void *, which is internally cast to an object pointer. After that my
library functions access the actual objects methods to perform the work
requested.
The shared header file is:
#ifdef __cplusplus
extern "C" {
#endif
void * Init(void);
void CleanUp(void *p);
void Display(void *p);
#ifdef __cplusplus
}
#endif
My initial experiment was successful. I.e. I created a test library
that hid an object, which was indirectly accessed by my test C
program. Inside the C++ library functions, I cast the void * to my
object:
void Display(void *p)
{
CNewClass *n = (CNewClass *) p;
cout << "The value is " << n->m_Value.c_str() << endl;
}
My object includes an STL string and the functions worked as I expected.
However, when I attempted to add an STL list member to my hidden object
(std::list<std::string> m_List;), suddenly, no matter what I tried, I
could not get the C program to link. BTW, I'm not really sure how to
interpret the errors.
The link errors were (sorry about the length):
/usr/opt/osf1/usr/bin/ld:
Unresolved:
nullref__7__rwstd
nullref_initialized__7__rwstd
__as__Q13std60basic_string__TcQ13std15char_traits__TcQ13std13allocator__
TvXPCc
__ct__Q13std60basic_string__TcQ13std15char_traits__TcQ13std13allocator__
TvXPCcRCQ13std13allocator__Tv
erase__Q13std163list__TQ13std60basic_string__TcQ13std15char_traits__TcQ1
3std13allocator__TvQ13std80allocator__TQ13std60basic_string__TcQ13std15c
har_traits__TcQ13std13allocator__TvXQ23std163list__TQ13std60basic_string
__TcQ13std15char_traits__TcQ13std13allocator__TvQ13std80allocator__TQ13s
td60basic_string__TcQ13std15char_traits__TcQ13std13allocator__Tv8iterato
rQ23std163list__TQ13std60basic_string__TcQ13std15char_traits__TcQ13std13
allocator__TvQ13std80allocator__TQ13std60basic_string__TcQ13std15char_tr
aits__TcQ13std13allocator__Tv8iterator
deallocate_buffers__Q13std163list__TQ13std60basic_string__TcQ13std15char
_traits__TcQ13std13allocator__TvQ13std80allocator__TQ13std60basic_string
__TcQ13std15char_traits__TcQ13std13allocator__TvXv
The compile and link commands for the C program were:
cc -c -I../cpplib ctest.c
cc -o ctest ctest.o ../cpplib/libcpplib.a -lcxx
The compiler versions I am using are:
cc - System V Environment 4.0 (Digital 3.11)
cxx - DIGITAL C++ V6.1-027 on DIGITAL UNIX V4.0 (Rev. 1229)
I must have tried dozens of combinations of linking order and libraries
with libcxx.a, libcxxstd.a, .so, etc. but still no luck. I would
appreciate any assistance, including an understanding of how to
interpret the link errors.
Thanks,
Bruce
Sent via Deja.com
http://www.deja.com/
next reply other threads:[~2001-01-11 18:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-11 18:11 bjb [this message]
2001-01-11 20:24 ` Problem linking C++ library with C program Rajanish Calisa
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox