From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,99f66b29f71185f2 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-01-11 12:22:07 PST From: "Rajanish Calisa" Newsgroups: comp.unix.tru64 References: <93kt0e$frh$1@nnrp1.deja.com> Subject: Re: Problem linking C++ library with C program X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Message-ID: NNTP-Posting-Host: 1cust159.tnt7.syd2.da.uu.net X-Trace: ozemail.com.au 979244264 63.34.224.159 (Fri, 12 Jan 2001 07:17:44 EST) NNTP-Posting-Date: Fri, 12 Jan 2001 07:17:44 EST Organization: OzEmail Ltd, Australia Distribution: world Date: Fri, 12 Jan 2001 07:24:24 +1100 Path: supernews.google.com!sn-xit-03!supernews.com!freenix!isdnet!newsfeeds.belnet.be!news.belnet.be!skynet.be!newspeer.clara.net!news.clara.net!news-hub.cableinet.net!uunet!ash.uu.net!news01.one.net.au!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail Xref: supernews.google.com comp.unix.tru64:1417 [*snip*] > > 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 > [*snip*] > cc -c -I../cpplib ctest.c > cc -o ctest ctest.o ../cpplib/libcpplib.a -lcxx > Use the C++ compiler to link: cc -c -I../cpplib ctest.c cxx -o ctest ctest.o -L../cpplib/ -lcpplib Make sure that the template instantiations present in cxx_repository are put into the libcpp.a archive, alternatively you can create a shared library using the command "cxx -shared -o libcpplib.so "; This will automatically put all the instantiations in the shared library. You did not get this problem when you used :string" because, the instantiation of template basic_string is present in libcxx.so. You can verify that you will get linker errors with your original version if you had compiled all you C++ files with -D__FORCE_INSTANTIATIONS. Check the C++ headers for details on this. Hope this helps. rajanish...