staticfloat
staticfloat

Reputation: 7040

WinRT C++ inter-dependencies not linking properly

I have a C++ WinRT component that I want to use from another, both of which are being used from a C# class that oversees the whole business. The C# class passes C++ class A a reference to C++ class B, and C++ class A can use B's methods just fine for compilation, but linking gets angry at me:

CameraTextureGraphConnector.obj : error LNK2019: unresolved external symbol "public: void __cdecl TextureGraph::TextureRenderer::setTexturePtr(unsigned int,unsigned int,unsigned int)" (?setTexturePtr@TextureRenderer@TextureGraph@@Q$AAAXIII@Z) referenced in function __unwind$5

Essentially, I'm trying to link against something in a separate .dll, but I don't know how to connect the dots. Trying to link with a .lib won't work here, as the other C++ component needs to generate a .dll to be consumed by C#. I've tried adding the other project as a Reference in the Project properties, but that doesn't seem to have any effect, and any attempt to play around with the parameters in that Reference page results in the defaults being loaded as soon as you hit "Apply".

Does anyone have any experience linking these objects together? Thank you!

Upvotes: 1

Views: 399

Answers (1)

staticfloat
staticfloat

Reputation: 7040

I figured it out. First, you should not #include .h files from other WinRT objects, you just add their references to your project in the project settings as described above. Secondly, you must declare all classes that you wish to use from the outside as public classes, e.g.:

public ref class TextureRenderer sealed {
    ...
}

As opposed to:

ref class TextureRenderer sealed {
    ...
}

Upvotes: 1

Related Questions