V
vivekanandaprasanth
hi,
I have exported a class which i have written in win32 static lib app.
Now i have written a wrapper class for the same. But when i am trying
to compile it is giving me some linker errors. Here is the class
information
//This is MyClass.h file
#define DllImport __declspec( dllimport )
#define DllExport __declspec( dllexport )
class DllExport CMyClass
{
public:
CMyClass();
int GetSum(int a, int b);
};
//This is MyClass.cpp file
#include "MyClass.h"
CMyClass::CMyClass()
{
}
int CMyClass::GetSum(int a, int b)
{
return a+b;
}
After this i have created a .net class library in which i want to use
this class
// WrapperClasseApp.h
#pragma once
using namespace System;
using namespace System::Runtime::InteropServices;
#include "D:\New Projects\MyStaticLib\MyClass.h"
namespace WrapperClasseApp
{
public __gc class Class1
{
// TODO: Add your methods for this class here.
private:
CMyClass *m_pClass;
public:
Class1::Class1(void)
{
m_pClass = new CMyClass();
}
Class1::~Class1(void)
{
delete m_pClass;
}
int WrapperForGetSum(System::Int32 a, System::Int32 b)
{
int iResult = m_pClass->GetSum(a,b);
return iResult ;
}
};
}
When i am trying to complie the above app, there are two linker errors
WrapperClasseApp.obj : error LNK2001: unresolved external symbol "void
* __cdecl operator new(unsigned int)" (??2@$$FYAPAXI@Z)
WrapperClasseApp.obj : error LNK2001: unresolved external symbol "void
__cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
can any one please help me how i can use the exported class and its
members
I have exported a class which i have written in win32 static lib app.
Now i have written a wrapper class for the same. But when i am trying
to compile it is giving me some linker errors. Here is the class
information
//This is MyClass.h file
#define DllImport __declspec( dllimport )
#define DllExport __declspec( dllexport )
class DllExport CMyClass
{
public:
CMyClass();
int GetSum(int a, int b);
};
//This is MyClass.cpp file
#include "MyClass.h"
CMyClass::CMyClass()
{
}
int CMyClass::GetSum(int a, int b)
{
return a+b;
}
After this i have created a .net class library in which i want to use
this class
// WrapperClasseApp.h
#pragma once
using namespace System;
using namespace System::Runtime::InteropServices;
#include "D:\New Projects\MyStaticLib\MyClass.h"
namespace WrapperClasseApp
{
public __gc class Class1
{
// TODO: Add your methods for this class here.
private:
CMyClass *m_pClass;
public:
Class1::Class1(void)
{
m_pClass = new CMyClass();
}
Class1::~Class1(void)
{
delete m_pClass;
}
int WrapperForGetSum(System::Int32 a, System::Int32 b)
{
int iResult = m_pClass->GetSum(a,b);
return iResult ;
}
};
}
When i am trying to complie the above app, there are two linker errors
WrapperClasseApp.obj : error LNK2001: unresolved external symbol "void
* __cdecl operator new(unsigned int)" (??2@$$FYAPAXI@Z)
WrapperClasseApp.obj : error LNK2001: unresolved external symbol "void
__cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
can any one please help me how i can use the exported class and its
members