Domanda

I have an absurdly simple managed (CLI Interop) function calling an unmanaged function:

void ManagedZigBeeTransport::StartDiscovery(void)
{
    std::list<sDeviceEndPoint> devices = zbTransport->startDiscovery();
}

where zbTransport is an unmanged object. I have several other examples of methods in this unmanaged object that that are called in similar managed wrappers without a problem and they all work. However, they do not have a return value. This one does.

It gives me the dreaded

CppBridgeTransports.obj : error LNK2028: unresolved token (0A00033B) "public: class std::list<struct _sDeviceEndPoint,class std::allocator<struct _sDeviceEndPoint> > __thiscall ZBTransport::startDiscovery(void)" (?startDiscovery@ZBTransport@@$$FQAE?AV?$list@U_sDeviceEndPoint@@V?$allocator@U_sDeviceEndPoint@@@std@@@std@@XZ) referenced in function "public: void __clrcall CppBridge::ManagedZigBeeTransport::StartDiscovery(void)" (?StartDiscovery@ManagedZigBeeTransport@CppBridge@@$$FQ$AAMXXZ)

followed by

CppBridgeTransports.obj : error LNK2019: unresolved external symbol "public: class std::list<struct _sDeviceEndPoint,class std::allocator<struct _sDeviceEndPoint> > __thiscall ZBTransport::startDiscovery(void)" (?startDiscovery@ZBTransport@@$$FQAE?AV?$list@U_sDeviceEndPoint@@V?$allocator@U_sDeviceEndPoint@@@std@@@std@@XZ) referenced in function "public: void __clrcall CppBridge::ManagedZigBeeTransport::StartDiscovery(void)" (?StartDiscovery@ManagedZigBeeTransport@CppBridge@@$$FQ$AAMXXZ)

I have not been able to apply any of the information I have seen in these threads that have functioned (some pretty simple like adding the std::list<> header file ).

The unmanaged sDeviceEndPoint structure is also defined in a header file. The idea was to obtain this unmanaged std::list<> and use it to load a managed ArrayList(). But I can't even get by this simple step. I don't know what is causing the problem, the std::list or the sDeviceEndPoint struct. The latter is successfully used in other parts of this unmanaged to managed bridge.

Any ideas?

Is it due to name mangling conventions from the return value that I do not understand?

È stato utile?

Soluzione

I am embarrassed as hell! I tested a series of simple functions between managed and unmanaged code, from returning a simple int to a struct, to a vector of structs and to a list of structs. Even passed these fields in as a parameter.

They all worked.

What did I do wrong???

Idiot that I was I forgot I had not yet implemented the original stupid function. All my tests, were, of course, implemented! So my original discovery function was declared but had no implementation. AARRGG! All day I have spent on this.

(I would have never guessed that was the reason for the error message.)

Maybe this will save someone else who gets the same sets of messages for the same reason.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top