I have just starting coding in my new mac. But whenever i make a program that contains other program files to link. It always shows this arm64 architecture error, i am unable to resolve it. For ex:
These are the programs i am trying to create:
//my.cpp
#include "my.h"
#include <iostream>
using namespace std;
void print_foo(){
cout<<foo<<"\n";
}
void print(int i){
cout<<i<<"\n";
}
//my.h
#ifndef MY_H
#define MY_H
extern int foo;
void print_foo();
void print(int);
#endif //MY_H
//user.cpp
#include "my.h"
int main(){
foo = 7;
print_foo();
print(99);
}
and this is my Makefile program
output: user.o my.o
g++ user.o my.o -o output
user.o: user.cpp
g++ -c user.cpp
my.0: my.o my.h
g++ -c my.cpp
clean:
rm*.o output
This is the output i am getting on running the program:
2
1
5.3k