Search code examples
cinclude

error: linker command failed with exit code 1


I get the error:

ndefined symbols for architecture x86_64:
  "_setVal", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1

I looked up other posts but nothing seems so solve the problem. I think that I used include properly.

main.c:

#include "game.h"

int main(int argc, char *argv[]) {
setVal(board, 1, 0, 6);
}

game.h:

#ifndef GAME_H_
#define GAME_H_

bool SetVal(Board* board, int row, int col, int value);

#endif

game.c:

#include "game.h"

bool SetVal(Board* board, int row, int col, int value){
// code in here
}

What can be cause of the error? Thank you.


Solution

  • Typo:

    int main(int argc, char *argv[]) {
        SetVal(board, 1, 0, 6);
    //  ^
    }