2013-07-17 6 views
0

두 개의 프로젝트가 있습니다. 하나는 DLL을 만들고 다른 하나는 DLL에 선언 된 함수를 사용해야합니다. 그러나이 문제를 구현하는 데 문제가 있습니다. 나는이 문제를 가지고있는 DLL 기능을 사용하는 프로젝트에서DLL C++에서 함수 가져 오기 문제. LNK 2001

using namespace XClass; 

extern "C" __declspec(dllexport) int Compute(XClass::XClassInput input, XClassOutput &XClassOutput); 

extern "C" __declspec(dllexport) int Init(string configFileName); 

class xclass 
{ 

public: 
    xclass(void); 
    xclass(constellation &Constellation, XClass::XClassConfig &XClassConfig); 

    void ComputeWeightingMatrix(constellation &xclass_constellation, char flagIntCont); 
    void ComputeGMatrix(constellation &Constellation, XClass::XClassInput &input); 

private: 
    int _numberOfSystemStates; 
}; 

: 다음 DLL 프로젝트에서

나는이 선언이

int _tmain(int argc, _TCHAR* argv[]) 
{ 

    XClass::XClassConfig xClassConfig; 
    XClassOutput xClassOutput; 

    XClass::XClassInput input; 

    init(input, xClassOutput); 

    constellation* class_constellation = new constellation(input, xClassConfig); 

    xclass* algorithm = new xclass(*xclass_constellation, xClassConfig); 


    algorithm->ComputeWeightingMatrix(*xclass_constellation, 'i'); 


    return 0; 
} 

ComputeWeighting 매트릭스 기능의 코드 :

void xclass::ComputeWeightingMatrix(constellation &Constellation, char flagIntCont) 
    { 
     double sigma = 0.0; 
     long error; 

      ... 
    } 

나는 빌드하려고 할 때 :

오류 LNK2001 : 일부 토론 후 "무효 __thiscall의 xclass :: ComputeWeightingMatrix (클래스 별자리 &, 문자) 공개"(ComputeWeightingMatrix @ xclass @@ $$ FQAEXAAVconstellation @@ D @ Z?)

+0

그렇다면'xclass :: ComputeWeightingMatrix'에 대한 코드는 어디에 있습니까? –

+0

함수의 내용과 관련이 있습니까? 아니면 그냥 선언? – DCuser

+0

코드 정의는 어디에 있으며 코드를 작성하는 방법은 무엇입니까? ] –

답변

1

되지 않은 외부 기호 채팅,이 문제의 해결책을 두 부분으로 밝혀졌습니다 :

  1. DLL 클래스에서 스텁 라이브러리를 사용해야합니다.
  2. 클래스의 기능을 내보내려면 class __declspec(dllexport) XClass을 사용해야합니다.