Hi,
I've been working in JavaScript and other languages for years and finally decided to take a stab at C and C++. I'm taking a decent online course for experienced JavaScript developers to learn C, and it's been great so far just using the stdlib. But as soon as I start working with my own functions, I start getting compiler errors.
misc.h
Code:
#ifndef MISC_H_
#define MISC_H_
void say_hi(void);
void say_thanks(void);
void say_bye(void);
#endif // MISC_H_
misc.c
Code:
#include <stdio.h>
#include "./misc.h"
void say_hi(void) {
puts("Hi!");
}
void say_thanks(void) {
puts("Thanks!");
}
void say_bye(void) {
puts("Bye!");
}
main.c
Code:
#include <stdio.h>
#include "./misc.h"
int main(void) {
say_hi();
say_thanks();
say_bye();
// printf("Hello, World!\n");
return 0;
}
If I comment out my functions, and uncomment the printf above, it compiles just fine. If I compile the above, as is, however, I get:
Code:
Undefined symbols for architecture arm64:
"_say_bye", referenced from:
_main in main-59cdf6.o
"_say_hi", referenced from:
_main in main-59cdf6.o
"_say_thanks", referenced from:
_main in main-59cdf6.o
ld: symbol(s) not found for architecture arm64
Obviously this has something to do with the fact that I'm on an M1 Mac and not on an Intel or AMD machine. But I have no idea what nor how to resolve this issue. I know that the regular gcc compiler doesn't support M1s, but I assumed Apple's compiler would. What am I missing?