A
Allen
In vc2005, I create a dll name ByteBuffer.dll, which export 3 classes,
i.e. ByteBuffer, ReadByteBuffer and WriteByteBuffer. The source code
is somewhat as following.
#ifndef _BYTE_BUFFER_H_
#define _BYTE_BUFFER_H_
class BYTEBUFFER_API ByteBuffer
{
public:
ByteBuffer(void);
virtual ~ByteBuffer(void);
void Wrap(void * pBuffer, const INT32 nLength);
void SetOrder(const INT32 nOrder = BORDER::OrderLitEndian);
...
};
#endif /* _BYTE_BUFFER_H_ */
Now my workmates want to use these 3 classes in MinGW.
For example, there is a test.cpp.
#include "WriteByteBuffer.h"
int main()
{
char buffer[512];
WriteByteBuffer writer;
writer.Wrap(buffer, 512);
writer.Set((INT32)12);
return 0;
}
I do like this:
d:\mingw\bin> pexports ByteBuffer.dll >ByteBuffer.def
d:\mingw\bin> g++ -o test test.cpp -I../include -L./ -lByteBuffer
But link fails with errors:
cciAKM3R.o:test.cpp.text+0x82): undefined reference to
`WriteByteBuffer::WriteByteBuffer()'
cciAKM3R.o:test.cpp.text+0xac): undefined reference to
`ByteBuffer::Wrap(void*, int)'
cciAKM3R.o:test.cpp.text+0xc2): undefined reference to
`WriteByteBuffer::Set(int)'
cciAKM3R.o:test.cpp.text+0xda): undefined reference to
`WriteByteBuffer::~WriteByteBuffer()'
cciAKM3R.o:test.cpp.text+0x119): undefined reference to
`WriteByteBuffer::~WriteByteBuffer()'
collect2: ld returned 1 exit status
How can I solve the problem? Please help me.
Thank you.
Allen
i.e. ByteBuffer, ReadByteBuffer and WriteByteBuffer. The source code
is somewhat as following.
#ifndef _BYTE_BUFFER_H_
#define _BYTE_BUFFER_H_
class BYTEBUFFER_API ByteBuffer
{
public:
ByteBuffer(void);
virtual ~ByteBuffer(void);
void Wrap(void * pBuffer, const INT32 nLength);
void SetOrder(const INT32 nOrder = BORDER::OrderLitEndian);
...
};
#endif /* _BYTE_BUFFER_H_ */
Now my workmates want to use these 3 classes in MinGW.
For example, there is a test.cpp.
#include "WriteByteBuffer.h"
int main()
{
char buffer[512];
WriteByteBuffer writer;
writer.Wrap(buffer, 512);
writer.Set((INT32)12);
return 0;
}
I do like this:
d:\mingw\bin> pexports ByteBuffer.dll >ByteBuffer.def
d:\mingw\bin> g++ -o test test.cpp -I../include -L./ -lByteBuffer
But link fails with errors:
cciAKM3R.o:test.cpp.text+0x82): undefined reference to
`WriteByteBuffer::WriteByteBuffer()'
cciAKM3R.o:test.cpp.text+0xac): undefined reference to
`ByteBuffer::Wrap(void*, int)'
cciAKM3R.o:test.cpp.text+0xc2): undefined reference to
`WriteByteBuffer::Set(int)'
cciAKM3R.o:test.cpp.text+0xda): undefined reference to
`WriteByteBuffer::~WriteByteBuffer()'
cciAKM3R.o:test.cpp.text+0x119): undefined reference to
`WriteByteBuffer::~WriteByteBuffer()'
collect2: ld returned 1 exit status
How can I solve the problem? Please help me.
Thank you.
Allen