2014-02-26 37 views
0

面临的一些问题在这里:C++ DLL导出错误LNK2019联动

WAZ是在一个名为DLL测试

Waz.h 

// Import/Export Pattern 
#ifdef TEST_EXPORTS 
#define DllExport __declspec(dllexport) 
#else 
#define DllExport __declspec(dllimport) 
#endif 

#pragma once 
#ifndef __Test__Waz__ 
#define __Test__Waz__ 

#include "WazImpl.h" 

class DllExport Waz 
{ 
/* Friends */ 
friend class WazImpl; 
friend Waz operator*(const Waz &,const Waz &); 

private: 

WazImpl *p; 
... 
public: 
... 
}; 

#endif /* defined(__Test__Waz__) */ 

Waz operator*(const Waz &,const Waz &); 

------- 

Waz.cpp 
(all def of the operator in public and ...) 
Waz operator*(const Waz & w1, const Waz & w2) 
{ 
Waz ww; 
*ww.p=*w1.p * *w2.p; 
return ww; 
} 


Then in the solution I have a console application and in my main 

int main() 
{ 
Waz a; 
a(1,1) =3 ; // this line works fine operator() is defined in the public of the Waz class 
Waz b; 
Waz c = a*b; // ERROR 

ERROR: 
error LNK2019 : unresolved external symbol "class Waz __cdecl operator*(class Waz const &, class Waz const &)" ([email protected][email protected]@[email protected]@Z) referenced in the function _main 
error LNK1120 : 1 unresolved external symbol 

基于一个事实,即(1,1)的作品就意味着类的运营商正确导出并且问题仅来自朋友操作员*! 有什么想法?不知道该怎么办了解决这个.. 在此先感谢!

+0

你应该给反馈来回答你了。请参阅http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – manuell

回答

0

操作员被声明的类外,只是将其导出,以:

DllExport Waz operator*(const Waz &,const Waz &);