Reputation: 193
I'm following this http://www.codeproject.com/Articles/10020/Using-managed-code-in-an-unmanaged-application
The example consist of 3 binaries:
The C++ code calls on the C++/CLI code, which then calls on the C# code, to achieve a way of running C# codes from C++.
The problem is, the C++/CLI is compiled as a .dll, when I tried to compile it into .lib, so that the C++ code and be linked together with the C++/CLI code, it fails.
So that the end result will only consist of 2 binaries.
The error
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl IMessageBoxWrapper::Destroy(class IMessageBoxWrapper *)" (__imp_?Destroy@IMessageBoxWrapper@@SAXPAV1@@Z) referenced in function _main C:\Users\Zero\Desktop\UmanagedApp\UmanagedApp\main.obj UmanagedApp
Error 2 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class IMessageBoxWrapper * __cdecl IMessageBoxWrapper::CreateInstance(void)" (__imp_?CreateInstance@IMessageBoxWrapper@@SAPAV1@XZ) referenced in function _main C:\Users\Zero\Desktop\UmanagedApp\UmanagedApp\main.obj UmanagedApp
Upvotes: 2
Views: 1138
Reputation: 283694
Since you no longer have a DLL, you shouldn't be using __declspec(dllimport)
at all.
Actually, I strongly discourage using that on classes in any case, it's very fragile.
So just remove DLLAPI
from all the class definitions.
Upvotes: 1