How to wrap a win32 class?

K

kathy

I have posted my problem before and still not feel confused. Anyone
know what is the problem?

In my Win32 dll, I defined:

#ifdef DllExport
#define UNMANAGED_API __declspec(dllexport)
#else
#define UNMANAGED_API __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C" {
#endif

struct UNMANAGED_API MyData
{
int data1;
int data2;
};

class UNMANAGED_API BubbleSort
{
private:
int *data;
int length;

public:
WINAPI BubbleSort(int *d, int l);
void WINAPI sort();
};

#ifdef __cplusplus
}
#endif

In my mixed mode VC++.NET class library:

public __gc class ManagedBubbleSort
{
// TODO: Add your methods for this class here.
private:
BubbleSort *pBSort;
public:
ManagedBubbleSort(int d __gc[], int l)
{
int *data;
int i;

data = new int[l];
for(i=0;i<l;i++)
data=d;

pBSort = new BubbleSort(data,l);
}
void managedBSort(){pBSort->sort();}
};

When I built my Class lib, I got:
"MyClassLib error LNK2001: unresolved external symbol "public: void
__thiscall BubbleSort::sort(void)" (?sort@BubbleSort@@$$FQAEXXZ)"
 
M

Micus

kathy said:
I have posted my problem before and still not feel confused. Anyone
know what is the problem?

In my Win32 dll, I defined:

#ifdef DllExport
#define UNMANAGED_API __declspec(dllexport)
#else
#define UNMANAGED_API __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C" {
#endif

struct UNMANAGED_API MyData
{
int data1;
int data2;
};

class UNMANAGED_API BubbleSort
{
private:
int *data;
int length;

public:
WINAPI BubbleSort(int *d, int l);
void WINAPI sort();
};

#ifdef __cplusplus
}
#endif

In my mixed mode VC++.NET class library:

public __gc class ManagedBubbleSort
{
// TODO: Add your methods for this class here.
private:
BubbleSort *pBSort;
public:
ManagedBubbleSort(int d __gc[], int l)
{
int *data;
int i;

data = new int[l];
for(i=0;i<l;i++)
data=d;

pBSort = new BubbleSort(data,l);
}
void managedBSort(){pBSort->sort();}
};

When I built my Class lib, I got:
"MyClassLib error LNK2001: unresolved external symbol "public: void
__thiscall BubbleSort::sort(void)" (?sort@BubbleSort@@$$FQAEXXZ)"


Is void BubbleSort::sort(void) defined somewhere with the proper #includes?
If not, that would be the problem. Otherwise, I don't know...

M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top