简体   繁体   中英

Undefined symbols for architecture x86_64 error when compiling

Very simply, I am getting this error:

Undefined symbols for architecture x86_64:
  "Tetris::rotate(int (*) [2], int)", referenced from:
      Tetris::add_piece(char, int, int) in tetris-8a8072.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

here is my rotate function:

int** rotate(int oldpiece[][2],int rot){
    int **newpiece= new int*[4];
    for (unsigned int i=0; i<4; ++i){
        newpiece[i] = new int[2];
    }
    for (unsigned int i=0; i<4; ++i){
        for (unsigned int j=0; j<2; ++j){
            newpiece[i][j]=oldpiece[i][j];
        }
    }
    return newpiece;
}

old piece is an 4x2 array of ints.

As of now all this function should do is copy oldpiece into newpiece and then return newpiece; . I have no idea what this error means.

Do you have an external library? if so, you must link it. Also, try compiling the program under release option instead of debug option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM