컴퓨터/디버깅
no matching function for call to
adnoctum
2010. 5. 24. 18:18
다음과 같은 에러가 났다.
환경: GCC 4.1.2 20080704 (Red Hat 4.1.2-46) on CentOS 5.4
NR_stat.cpp: In function ‘void ttest(const std::vector<double, std::allocator<double> >&, const std::vector<double, std::allocator<double> >&, double&, double&)’:
NR_stat.cpp:516: error: no matching function for call to ‘Beta::betai(double, double, double)’
NR_stat.cpp:240: note: candidates are: bool Beta::betai(double, double, double, double*)
NR_stat.cpp:516: error: no matching function for call to ‘Beta::betai(double, double, double)’
NR_stat.cpp:240: note: candidates are: bool Beta::betai(double, double, double, double*)
에러의 내용을 살펴 보면, NR_stat.cpp 파일에 있는 함수 void ttest(~~) 함수 안의, NR_stat.cpp 파일의 516번째 줄에서 함수
Beta::betai(double,double,double)
을 호출하고 있는데, 이 함수가 없다는 것이다. 위의 경우 unresolved external symbol 과 같은 에러가 나지 않는 이유는 컴파일만 했기 때문인데, 즉,
g++ -c NR_stat.cpp
와 같은 명령어로 작업을 했기 때문이다. 어찌되었든 Beta::betai 함수 중 double 형 parameter 3개를 받는 함수를 호출했는데 그와 같은 형태의 함수가 없다는 것이다. gcc 의 경우 아마도 이런 함수를 호출하려고 했던 것 아니냐, 하는 의미에서
NR_stat.cpp:240: note: candidates are: bool Beta::betai(double, double,
double, double*)
과 같은 함수가 있다고 알려 주고 있다. VC++ 의 경우 이와 같은 말이 나오지는 않는 것 같다.
따라서 위와 같은 경우, 함수 호출 부분을 수정하거나, 함수 호출 부분은 그대로 두고 대신 호출된 함수와 prototype 이 같은 함수를 만들어야 할 것이다.