问题描述
1> yes.obj:error LNK2019:无法解析的外部符号int __cdecl availableMoves(int * (void)__cdecl solveGame(int * const,int(* const)[4])(?solveGame @@)中引用的const,int(* const)[4],int)(?availableMoves @@ YAHQAHQAY03HH @ Z) YAXQAHQAY03H @ Z)
我以前从未见过这个错误。以下是我相信它指的两个函数。
int availableMoves(int a [15],int b [36] [3],int openSpace){
int count = 0;如果(i count ++;
}
}
return count;
}
和
void solveGame(int a [15],int b [36] [4]){
int empSpace;
int movesLeft; (pegCount(a) cout <<} else {
empSpace = findEmpty(a);
if(movesLeft = availableMoves(a,b,empSpace)< 1){
temp [index] = empSpace;
d--;
c [d] [0] = 0;
c [d] [1] = 0;
c [d] [2] = 0;
c [d] [3] = 0;
a [b [c [d] [3]] [0]] = 1;
a [b [c [d] [3]] [0]] = 1;
a [b [c [d] [3]] [0]] = 0;
b [c [d] [3]] [3] = 0;
index ++;
} else if(movesLeft> = 1){
chooseMove(a,b,empSpace);
index = 0;
for(int i = 0; i temp [i] = -1;
}
}
d ++;
solveGame(a,b);
$ / code $ / pre
解决方案当前声明与定义不符。
在使用它之前,您可能已经声明了函数
availableMoves()
,然后你实现了一个不同的函数:
pre $int availableMoves(int * const a,int(* const)[4], INT);
// ....
// ....
// ....
//使用可用移动的代码
int availableMoves(int a [15],int b [36] [3],int openSpace)
{
// ....
}
由于编译器先看到该声明,它将使用它来解析块中的调用的代码。但是,该函数不会导出,因为它具有不同的签名。
The error verbatim reads
1>yes.obj : error LNK2019: unresolved external symbol "int __cdecl availableMoves(int * const,int (* const)[4],int)" (?availableMoves@@YAHQAHQAY03HH@Z) referenced in function "void __cdecl solveGame(int * const,int (* const)[4])" (?solveGame@@YAXQAHQAY03H@Z)
I've never seen this error before. Here are the two functions I believe it's referring to though.
int availableMoves(int a[15], int b[36][3],int openSpace){
int count=0;
for(int i=0; i<36;i++){
if(i < 36 && b[i][2] == openSpace && isPeg(b[i][0],a) && isPeg(b[i][1],a) ){
count++;
}
}
return count;
}
and
void solveGame(int a[15], int b[36][4]) {
int empSpace;
int movesLeft;
if(pegCount(a) < 2) {
cout<<"game over"<<endl;
} else {
empSpace = findEmpty(a);
if(movesLeft = availableMoves(a,b,empSpace) < 1 ) {
temp[index] = empSpace;
d--;
c[d][0] = 0;
c[d][1] = 0;
c[d][2] = 0;
c[d][3] = 0;
a[b[c[d][3]][0]] = 1;
a[b[c[d][3]][0]] = 1;
a[b[c[d][3]][0]] = 0;
b[c[d][3]][3] = 0;
index++;
} else if(movesLeft >= 1) {
chooseMove( a, b, empSpace);
index = 0;
for(int i=0; i<4; i++) {
temp[i] = -1;
}
}
d++;
solveGame( a, b);
}
}
Your current declaration doesn't match the definition.
You probably have declared the function availableMoves()
before you use it, but then you implement a different function:
int availableMoves(int* const a, int (* const)[4] , int);
//....
//....
//....
//code that uses available moves
int availableMoves(int a[15], int b[36][3],int openSpace)
{
//....
}
Since the compiler sees that declaration first, it will use it to resolve the call in the block of code. However, that function is not exported, as it has a different signature.
这篇关于LNK2019错误,无法解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!