Note that there are some explanatory texts on larger screens.

plurals
  1. POI don't understand this link error
    primarykey
    data
    text
    <p>I don't understand this link error. I have 2 classes:</p> <pre><code>#include "Vector3.h" #include "Quaternion.h" template&lt;typename T&gt; class Point3 final { public: constexpr Point3(const Vector3&lt;T&gt;&amp; vec) : x(vec.x), y(vec.y), z(vec.z) {} constexpr operator const Vector3&lt;T&gt;() const { // It is the equivalent of Vector3 = Point3 - Origin return Vector3&lt;T&gt;(x, y, z); } constexpr operator Vector3&lt;T&gt;() const { // It is the equivalent of Vector3 = Point3 - Origin return Vector3&lt;T&gt;(x, y, z); } T x = T(0); T y = T(0); T z = T(0); friend Vector3&lt;T&gt;; friend Quaternion&lt;T&gt;; friend Vector3&lt;T&gt; operator*( const Quaternion&lt;T&gt;&amp; lhs, const Vector3&lt;T&gt;&amp; rhs); friend Vector3&lt;T&gt; operator*( Vector3&lt;T&gt; lhs, const Vector3&lt;T&gt;&amp; rhs); }; typedef Point3&lt;Float32&gt; Point3f; </code></pre> <p>and</p> <pre><code>template&lt;typename T&gt; class Vector3 final { public: constexpr Vector3() {} constexpr Vector3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {} T x = T(0); T y = T(0); T z = T(0); }; typedef Vector3&lt;Float32&gt; Vector3f; </code></pre> <p>I also have a Quaternion class the detail are irrelevant i beleive but this class has a non member operator*:</p> <pre><code> template&lt;typename T&gt; Vector3&lt;T&gt; operator*( const Quaternion&lt;T&gt;&amp; lhs, const Vector3&lt;T&gt;&amp; rhs) { // nVidia SDK implementation Vector3&lt;T&gt; qvec(lhs.x, lhs.y, lhs.z); Vector3&lt;T&gt; uv = cross(qvec, rhs) * T(2.0) * lhs.w; //uv = qvec ^ v; Vector3&lt;T&gt; uuv = cross(qvec, uv) * T(2.0); //uuv = qvec ^ uv; return rhs + uv + uuv; } </code></pre> <p>Now those line produce a link error, but why?</p> <pre><code>Math::Point3&lt;Float32&gt; pt = -Math::Point3&lt;Float32&gt;::UNIT_Z; Math::Vector3&lt;Float32&gt; vec = orientation_*pt; // link error here (orientation is a Quaternion&lt;Float32&gt;) //Math::Vector3&lt;Float32&gt; vec = orientation_*Math::Vector3&lt;Float32&gt;(pt); // this solve the link error. </code></pre> <p>Here is the link error</p> <pre><code>Undefined symbols for architecture x86_64: Math::operator*(Math::Quaternion&lt;float&gt; const&amp;, Math::Vector3&lt;float&gt; const&amp;), referenced from: GfxObject::Procedural::BoxGenerator::addToTriangleBuffer(GfxObject::Procedural::TriangleBuffer&amp;) const in ProceduralBoxGenerator.o </code></pre> <p><strong>Update</strong></p> <p>I found 2 question that are really close to this but the problem relies in the differences.</p> <p>in: <a href="https://stackoverflow.com/questions/10375626/implicit-conversion-lookup-on-template-fails-for-friend-function-defined-outside">question 1</a> and <a href="https://stackoverflow.com/questions/8890051/implicit-conversion-when-overloading-operators-for-template-classes">question 2</a></p> <p>But in my case I need to convert between 2 templates classes instead of the same class but 2 instantions. I hope this will help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload