Expand|Select|Wrap|Line Numbers
- // *************************
- // IN THE HEADER FILE
- // *************************
- #pragma once
- #ifdef EXPORTS
- #define MYAPI __declspec(dllexport)
- #else
- #define MYAPI __declspec(dllimport)
- #endif
- class MYAPI NNative
- {
- public:
- NNative();
- int DoSomething(); // just returns the integer 1000.
- };
- // *************************
- // IN THE CPP FILE
- // *************************
- #include "CliLib.h"
- NNative::NNative()
- {
- }
- int NNative::DoSomething()
- {
- return 1000;
- }
Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include "..\CliLib\CliLib.h"
- using namespace System;
- int main(array<System::String ^> ^args)
- {
- NNative *pn = new NNative();
- Console::WriteLine(String::Format("You got {0}", pn->DoSomething()));
- delete pn;
- return 0;
- }
1. The DLL still builds fine.
2. The main app produces 2 linker error for each public symbol of the NNative class: LNK2028 and LNK2019.
What am I doing wrong that I can't import the native class from the CLR DLL?
Thanks.