This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15407] Problem using shared library created from template class
- From: "uttamkumar at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 May 2004 19:43:25 -0000
- Subject: [Bug c++/15407] Problem using shared library created from template class
- References: <20040512193126.15407.uttamkumar@hotmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From uttamkumar at hotmail dot com 2004-05-12 19:43 -------
(In reply to comment #0)
> I have a template class declare in T.hpp and defined in T.cpp and want to
build
> a shared library and use that library to write an application. Only
application
> knows about the template(object) type.
> g++ -g -D_REENTRANT -frepo -O -W -Wall -Wno-unknown-pragmas -I. -I../h -
fPIC -
> c T.cpp
> It has created the T.rpo repository file.
> g++ -frepo -shared -o ../lib/libT.so -fPIC T.o
> Now build the app Th.
> g++ -g -D_REENTRANT -frepo -O -W -Wall -Wno-unknown-pragmas -I. -I../h -
fPIC -
> c Th.cpp
> It has created the Th.rpo file too.
> Now linking: and get the following errro.
> g++ Th.o -o Th -L../lib -lT -lpthread -lnsl -lsocket -lstdc++ -l c -l gcc_s
> Undefined first referenced
> symbol in file
> ThreadQueue<Msg>::GetMsg(long) Th.o
> ThreadQueue<Msg>::CreateThread(void* (*)(void*), void*)Th.o
> ThreadQueue<Msg>::PutMsg(Msg*) Th.o
> ThreadQueue<Msg>::ThreadQueue[in-charge](int)Th.o
> ld: fatal: Symbol referencing errors. No output written to Th
> collect2: ld returned 1 exit status
> --------------------------------------------------
> If I use collect2 for linking I get the follwoing error.
> collect2 Th.o -o Th -L../lib -l T -lpthread -lnsl -lsocket -lstdc++ -lc -
> lgcc_s
> collect: recompiling Th.cpp
> collect: recompiling T.cpp
> T.cpp: In member function `T* ThreadQueue<T>::GetMsg(long int)':
> T.cpp:53: warning: `std::vector<T*, std::allocator<T*> >::iterator'
> is implicitly a typename
> T.cpp:53: warning: implicit typename is deprecated, please see the
> documentation for details
> collect: recompiling Th.cpp
> collect: recompiling ThreadQueue.cpp
> and it goes to infinite recompiling loop.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15407