Skip to main content
gamedev.net
🔒 Locked

creating static library using bcb

Started by wsztm Jan 30, 2006 at 10:53 AM 0 replies 350+ views
Original Post
wsztm
wsztm
Hi all, recently i used bcb for creating static library, and i got some trickies :(

// header file
template <typename T>
class XVector   :   public Vector<T>
{
public:
    XVector();
    XVector(float x, float y, float z);

    XVector operator+(const XVector&) const;
};

// cpp file
template class XVector<float>;


XVector<float>::XVector()
{
    vx = 0.f;
    vy = 0.f;
    vz = 0.f;
}


XVector<float>::XVector(float x, float y, float z)
{
    vx = x;
    vy = y;
    vz = z;
}


XVector<float> XVector<float>::operator +(const XVector<float> &v) const
{
    return XVector<float>(vx + v.vx, vy + v.vy, vz + v.vz);
}



and I compile successfully. however, i add the lib into the project, and i always got the error: "[Linker Error] Unresolved external 'XVector::operator +(const XVector&) const' referenced from D:\STUDY\BCB_OP\3DMATH\X3DMATH.OBJ"


int main(int argc, char* argv[])
{
    XVector<float> v1(1.0f, 2.0f, 3.0f), v2(1.f, 2.f, 3.f);

    XVector<float> v3;

    cout<<v1.vx <<' ' <<v1.vy <<' ' <<v1.vz <<endl;

    v3 = v1 + v2;

    cout <<v3.vx <<' ' <<v3.vy <<' ' <<v3.vz <<endl;

    getchar();

    return 0L;
}


could anyone know how to solve the issues? thanx a lot
wsztm
wsztm
up

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.