From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,99f66b29f71185f2,start X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-01-11 10:24:21 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!nntp.primenet.com!nntp.gblx.net!newsfeed.cs.utexas.edu!galaxy.us.dell.com!news-feeds!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: bjb@plaza.ds.adp.com Newsgroups: comp.unix.tru64 Subject: Problem linking C++ library with C program Date: Thu, 11 Jan 2001 18:11:36 GMT Organization: Deja.com Message-ID: <93kt0e$frh$1@nnrp1.deja.com> Reply-To: bjb@NospaMplaza.ds.adp.com NNTP-Posting-Host: 139.126.32.100 X-Article-Creation-Date: Thu Jan 11 18:11:36 2001 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0) X-Http-Proxy: 1.0 PEPSI, 1.0 x54.deja.com:80 (Squid/1.1.22) for client 139.126.32.100 X-MyDeja-Info: XMYDJUIDbrucebailey3 Xref: supernews.google.com comp.unix.tru64:1416 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 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/