这个问题在这里已经有一个答案:>
What is an undefined reference/unresolved external symbol error and how do I fix it?27
我得到错误:
我得到错误:
main.o(.text+0x1ed): In function `main': : undefined reference to `avergecolumns' collect2: ld returned 1 exit status
当我gcc * .o.我不太确定是什么原因导致这个错误.其他海报已解释为功能未找到或功能为空.如果有人可以澄清或改进,那将是非常感谢!
#include "my.h" void averagecolumns (int x,int y,int** a) { int i; int j; float sum; float colAvg; sum = 0; colAvg = 0; printf("i. The column averages are: \n"); for(i = 0; i < x; i++) { for(j = 0; j < y; j++) { sum += a[i][j]; colAvg = sum / (float)x; } printf("Column: %3d,Average: %6.2f",j,colAvg); sum = 0; colAvg = 0; }
主要的主要部分有:
#include "my.h" int main (int argc,char* argv[]) { int** a; float** colAvg; int ROWS; int COLS; int i; int j; int** table; FILE* fpmyfile; int closeResult; .... printme (ROWS,COLS,a); // call functions a - j oddvalues (ROWS,a); oddlocations (ROWS,a); countoddrows (ROWS,a); addrows (ROWS,a); findfirstsmall (ROWS,a); findlastlarge (ROWS,a); addcolumns (ROWS,a); avergecolumns (ROWS,a); .... }