This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
problem creating a static library
- From: Danilo José <danilo dot guerrero at deimos-space dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Wed, 29 Sep 2004 19:59:51 +0200
- Subject: problem creating a static library
Hello I am having a problem creating a static library with gcc 2.95.2. In a
MacOSX system.
I have compiled the objects without any problem. I create the static
library using the ar command.
The thing is that when I use the library to build an executable it gives me
some errors of undefined symbols.
But if I use directly the objects the executable works correctly.
++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./..
/include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
ar crs -crv ./../lib/Mac_OS_10/libgol.a String.o StdError.o InputStream.o
JulianDate.o
ser.tab.o CalcScanner.tab.o lex.Calc.o ObjAppendListTypes.o
r - String.o
r - StdError.o
r - InputStream.o
r - JulianDate.o
r - RawBuffer.o
r - Args.o
r - Statistic.o
r - CalcParser.tab.o
r - CalcScanner.tab.o
r - lex.Calc.o
r - ObjAppendListTypes.o
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -o calc_test String.o StdError.o InputStream.o JulianDate.o RawBuffer.o
Args.o Stat
b.o lex.Calc.o ObjAppendListTypes.o
CalcTest.o -L./../lib/Mac_OS_10 -lgol -L/usr/lib -
g++ -c -DMacintosh -O2 -fvtable-thunks -frepo -fno-implicit-templates -I./.
./include -
g++ -o calc_test_bind
CalcTestBind.o -L./../lib/Mac_OS_10 -lgol -L/usr/lib -lstdc++ -lm
/usr/bin/ld: Undefined symbols:
___Q23golt13ObjAppendList1ZPQ23gol14CalcBinderDatalPCPB1
___Q23golt13ObjAppendList1ZblPCb
___ls__Q23golt13ObjAppendList1ZPQ23gol14CalcBinderDataRCPB1
___ls__Q23golt13ObjAppendList1ZbRCb
___Q23golt13ObjAppendList1ZPQ23gol8CalcNodelPCPB1
___Q23golt13ObjAppendList1ZPvlPCPv
___Q23golt13ObjAppendList1ZcRCB0
___Q23golt13ObjAppendList1ZclPCc
___as__Q23golt13ObjAppendList1ZcRCB0
___ls__Q23golt13ObjAppendList1ZPQ23gol8CalcNodeRCPB1
___ls__Q23golt13ObjAppendList1ZPvRCPv
_append__Q23golt13ObjAppendList1ZclPCc
_reverse__Q23golt13ObjAppendList1ZPQ23gol8CalcNode
make: *** [calc_test_bind] Error 1
So as you can see when building calc_test, there is no problem because it
uses the objects directly, but when using the library it fails.
I have checked the library with nm and this is what appears:
nm ../lib/Mac_OS_10/libgol.a | grep
___Q23golt13ObjAppendList1ZPQ23gol14CalcBinderDatalPCPB1 | c++filt
U gol::ObjAppendList<gol::CalcBinderData *>::ObjAppendList(long,
gol *const *)
U gol::ObjAppendList<gol::CalcBinderData *>::ObjAppendList(long,
gol *const *)
00000d30 S gol::ObjAppendList<gol::CalcBinderData *>::ObjAppendList(long,
gol *const *)
nm ObjAppendListTypes.o | grep
___Q23golt13ObjAppendList1ZPQ23gol14CalcBinderDatalPCPB1 | c++filt
00000d30 S gol::ObjAppendList<gol::CalcBinderData *>::ObjAppendList(long,
gol *const *)
ObjAppendListTypes.C is a file that has all the instantiations of the
templates needed by the code:
Like this:
namespace gol
{
template class ObjAppendList<char>;
template class ObjAppendList<unsigned char>;
template class ObjAppendList<signed char>;
template class ObjAppendList<short>;
template class ObjAppendList<unsigned short>;
template class ObjAppendList<long>;
template class ObjAppendList<unsigned long>;
template class ObjAppendList<long long>;
template class ObjAppendList<unsigned long long>;
template class ObjAppendList<float>;
template class ObjAppendList<double>;
template class ObjAppendList<String>;
template class ObjAppendList<const char*>;
template class ObjAppendList<int>;
template class ObjAppendList<bool>;
template class ObjAppendList<void *>;
template class ObjAppendListP<stringstream>;
template class ObjAppendList<stringstream*>;
template class ObjAppendListP<String>;
template class ObjAppendList<String*>;
template class ObjAppendListP<JulianDate>;
template class ObjAppendList<JulianDate*>;
template class ObjAppendList<RawBuffer *>;
template class ObjAppendListP<RawBuffer>;
template class ObjAppendList<CalcNode *>;
template class ObjAppendListP<CalcNode>;
template class ObjAppendList<CalcBinder *>;
template class ObjAppendListP<CalcBinder>;
template class ObjAppendList<CalcBinderData *>;
template class ObjAppendListP<CalcBinderData>;
} // namespace gol
#endif
The templates definition are in one .h file.