0

I encountered some link error using Eigen.

DX11Book.lib(Camera.obj) : error LNK2019: unresolved external symbol "public: void __cdecl VectorParameterWriterDX11::SetValue(class Eigen::Matrix<float,4,1,0,4,1> const &)" (?SetValue@VectorParameterWriterDX11@@QEAAXAEBV?$Matrix@M$03$00$0A@$03$00@Eigen@@@Z) referenced in function "public: void __cdecl Camera::RenderFrame(class RendererDX11 *)" (?RenderFrame@Camera@@QEAAXPEAVRendererDX11@@@Z)
1>D:\Code\DX11Book\x64\Debug\BasicWindow.exe : fatal error LNK1120: 1 unresolved externals

DX11Book is my engine project, compiled as a lib, while BasicWindow is a demo project. All in the same solution.

Declaration of the VectorParameterWriterDX11 in VectorParameterWriterDX11.h

class VectorParameterWriterDX11 : public ParameterWriter
{
public:
    VectorParameterWriterDX11();
    virtual ~VectorParameterWriterDX11();

    // 
    void SetRenderParameterRef(VectorParameterDX11* pParam);
    void SetValue(const Eigen::Vector4f& value);
    Eigen::Vector4f GetValue();

    // override virtual methods
    virtual RenderParameterDX11* GetRenderParameterRef() override;

    virtual void WriteParameter(IParameterManager* pParamMgr) override;

    virtual void InitializeParameter() override;

protected:
    VectorParameterDX11*    m_pParameter;
    Eigen::Vector4f             m_Value;

};

SetValue Definition in VectorParameterWriterDX11.cpp:

void VectorParameterWriterDX11::SetValue(const Eigen::Vector4f& value)
{
    m_Value = value;
}

In Camera::RenderFrame function (in Camera.cpp), there's a call to SetValue function.

m_pViewProjectionWriter->SetValue(Vector4f(p.x(), p.y(), p.z(), 1.0f));

The SetValue function would work correctly if I use 4 floats instead of Eigen vector. According to the document Eigen doesn't need to link to any libs/dlls. https://eigen.tuxfamily.org/dox/GettingStarted.html

Code above mainly from Jason Zink's DX11 rendering framework. but in the original code it doesn't use Eigen. https://github.com/matt77hias/Hieroglyph-v3

Any help/advice will be appreciated.

kagtag
  • 1
  • 1
  • 1
    The compiler doesn't find the *definition* corresponding to your call using this SetValue *declaration*.. How is SetValue *defined*? – Simon Mourier Aug 28 '21 at 10:53
  • @SimonMourier Just added the definition in the question description. Since the DX11Book.lib compiles correctly, I think there's no problem. – kagtag Aug 28 '21 at 13:14
  • Fixed by removing and adding the VectorParameterWriterDX11.cpp file, seems that the VS doesn't even compile it (no .obj file). I think there should be an error message if some cpp file in the project doesn't compile at all. – kagtag Sep 05 '21 at 05:45

0 Answers0