<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi all<br>
<br>
I'm currently writing C++ code that I want to use via Python with
SIP. The following is a skeleton for my code:<br>
<br>
<blockquote><i>template<class T><br>
class MyClass<br>
{<br>
</i><i>MyClass</i><i>(QString s);<br>
T* calculate();<br>
}<br>
<br>
class B<br>
{<br>
B();<br>
void doStuff();<br>
}<br>
<br>
void B::doStuff()<br>
{<br>
</i><i>MyClass</i><i><int> var("");<br>
int *var2 = var.calculate();<br>
}<br>
<br>
</i></blockquote>
The only class I've included in my SIP file is class B (and not
class A). Everything compiles correctly, but when QGIS starts, I get
a Python error:<br>
<br>
<blockquote><i> File
"/home/goocreations/apps/share/qgis/python/qgis/utils.py", line
283, in _import</i><br>
<i> mod = _builtin_import(name, globals, locals, fromlist,
level)</i><br>
<i>ImportError:
/home/goocreations/apps/lib/libqgis_mylib.so.1.7.0: undefined
symbol: _ZN15</i><i>MyClassIiEC1E7QString</i><br>
<br>
</blockquote>
This error seems strange, since I've never included MyClass in the
SIP files and the only place MyClass is instantiated is in my cpp
file (I didn't even include the MyClass directory in the cmake file
that handles the SIP files). So I'm a bit confused of how Python
gives an error on code that isn't linked to SIP.<br>
<br>
So, I've though that creating a SIP binding for MyClass may resolve
the issue, but I can't figure out how I would use templates in SIP.<br>
<br>
By the may: when I remove the template from MyClass and make
everything by default int, everything compiles and runs perfectly.<br>
<br>
Does anyone have an idea of why this is happening, or if I maybe
have to include something special in the cmake files?<br>
<br>
Thanks<br>
<br>
Chris<br>
</body>
</html>