This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15407] New: 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:31:28 -0000
- Subject: [Bug c++/15407] New: Problem using shared library created from template class
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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
ThreadQueue.cpp: In member function `T* ThreadQueue<T>::GetMsg(long int)':
ThreadQueue.cpp:53: warning: `std::vector<T*, std::allocator<T*> >::iterator'
is implicitly a typename
ThreadQueue.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.
--
Summary: Problem using shared library created from template class
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: uttamkumar at hotmail dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15407