0

I have interface.c:

#include "interface.h"

int main(){
}

int foo(int a, int b){
    return a+b;
}

And interface.h:

#ifndef UNTITLED_INTERFACE_H
#define UNTITLED_INTERFACE_H

int foo(int a, int b);

#endif //UNTITLED_INTERFACE_H

Now, test.c:

#include <stdio.h>
#include "interface.h"

int main(){

    printf("%d \n ", foo(3,4));

}

I compiled gcc test.c -o test but get this error:

Undefined symbols for architecture x86_64:
  "_foo", referenced from:
      _main in test-9668b6.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't know why? All files are in the same folder! I searched online I still see that I am following the right steps! Can someone hint me? Thank you.

Pedro Kali
  • 55
  • 1
  • 5

0 Answers0