在vc6.0中没有这个问题,在2010就编译通不过
都是使用的多字节,.lib文件都正确添加了,
测试代码如下:
void CCDataMatrixTestDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
// CDialogEx::OnOK();
CDataMatrix dataMatrix("", 10, 10);
}
错误信息如下
1>CDataMatrixTestDlg.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall CDataMatrix::CDataMatrix(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >,int,int)" (__imp_??0CDataMatrix@@QAE@V?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@HH@Z),该符号在函数 "public: void __thiscall CCDataMatrixTestDlg::OnBnClickedOk(void)" (?OnBnClickedOk@CCDataMatrixTestDlg@@QAEXXZ) 中被引用
1>E:\源码\CDataMatrixTest\Debug\CDataMatrixTest.exe : fatal error LNK1120: 1 个无法解析的外部命令
动态链接库的头文件类定义部分代码,其中AFX_EXT_CLASS 就是__declspec(dllimport)
class AFX_EXT_CLASS CDataMatrix
{
public:
CString GetErrorMessage(int iErrorCode);
unsigned char* iec16022ecc200(int *Wptr, int *Hptr, char **encodingptr,
int barcodelen, unsigned char *barcode,
int *lenp, int *maxp, int *eccp);
char* encmake(int l, unsigned char *s, int *lenp, char exact);
char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl, char *encoding, int *lenp);
void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock);
void ecc200placement(int *array, int NR, int NC);
void ecc200placementcornerD(int *array, int NR, int NC, int p);
void ecc200placementcornerC(int *array, int NR, int NC, int p);
void ecc200placementcornerB(int *array, int NR, int NC, int p);
void ecc200placementcornerA(int *array, int NR, int NC, int p);
void ecc200placementblock(int *array, int NR, int NC, int r, int c, int p);
void ecc200placementbit(int *array, int NR, int NC, int r, int c, int p, char b);
void rs_encode(int len, unsigned char *data, unsigned char *res);
void rs_init_code(int nsym, int index);
void rs_init_gf(int poly);
CDataMatrix(CString strBarcodeValue, int iWidth, int iHeight);
int Encode(CString &strReturn, int &width, int &height);
virtual ~CDataMatrix();
private:
//条码内容
CString m_strBarcodeValue;
//条码宽度
int m_iWidth;
//条码高度
int m_iHeight;
int gfpoly;
int symsize; // in bits
int logmod; // 2**symsize - 1
int rlen;
int *log;
int *alog;
int *rspoly;
};
链接库导出函数列表见下图
如有需要可以提供.h、.lib和dll测试