[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Forcing the instantiation of templates in a shared object
From: |
James Kanze |
Subject: |
Forcing the instantiation of templates in a shared object |
Date: |
Sun, 13 Mar 2005 21:48:42 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20041206) |
G++ 3.4.0 under Linux, for what it's worth.
I've got what should be a simple problem: I have a couple of
sources which basically do nothing but instantiate a template,
then declare a local variable of the instantiated type.
Regretfully, when I try to load the .so, I get the following
error:
Error in dlopen: ./objects/libUTF32LEInputTranslator.so: undefined
symbol: ConcreteInputTranslator<(anonymous
namespace)::UTF32LECharacterReader>::read(char*, char*, BasicInput&) const
For some reason, the template is not getting instantiated.
I've tried adding:
template class ConcreteInputTranslator<UTF32LEInputTranslator> ;
and:
template class
ConcreteInputTranslator<UTF32LEInputTranslator>::read(char*, char*,
BasicInput& ) const;
I've also tried adding a dummy function which called read on the
local object. All to no avail.
The command line I'm using to create the shared library is:
g++ -o objects/libUTF16BEInputTranslator.so -shared
objects/UTF16BEInputTranslator.o -rdynamic
The link of the main is:
g++ -o objects/test -ansi -ffor-scope -fno-gnu-keywords
-foperator-names -pipe -Wall -W -Wno-sign-compare -Wno-deprecated
-Wno-non-virtual-dtor -Wpointer-arith -Wno-unused -D_XOPEN_SOURCE
-D_XOPENSOURCE_EXTENDED -ggdb3 -fPIC -DSYSTEM=Unix -I. -I../include
-I../sources
-I/home/kanze/libs/gabi-stable/include/conf/i80x86/linux/gcc3
-I/home/kanze/libs/gabi-stable/include
-I/home/kanze/libs/gabi-stable/sources/conf/i80x86/linux/gcc3
-I/home/kanze/libs/gabi-stable/sources -L../lib
-L/home/kanze/libs/gabi-stable/lib/i80x86/linux/gcc3 objects/testmain.o
objects/libtest.a objects/libInput.a -lSystem -lUtil -lProcess-d -lIO-d
-lText-d -lBasic-d -lTest-d -lPort-d -ldl -rdynamic
Logically, I don't think that this should play a role; there's
nothing in the main which uses the template in question.
--
James Kanze home: www.gabi-soft.fr
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 pl. Pierre Sémard, 78210 St.-Cyr-l'École, France +33 (0)1 30 23 00 34
- Forcing the instantiation of templates in a shared object,
James Kanze <=