Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: "Rajanish Calisa" <rcalisa@ozemail.com.au>
Subject: Re: Problem linking C++ library with C program
Date: Fri, 12 Jan 2001 07:24:24 +1100	[thread overview]
Message-ID: <Ixo76.10$Jy6.1517@ozemail.com.au> (raw)
In-Reply-To: 93kt0e$frh$1@nnrp1.deja.com

[*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<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
>

[*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 <object
files>";
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<char> 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...




      reply	other threads:[~2001-01-11 20:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-11 18:11 Problem linking C++ library with C program bjb
2001-01-11 20:24 ` Rajanish Calisa [this message]
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