Question
I keep getting an error Undefined symbols for architecturex86_64 & ld: symbol(s) not found for architecture x86_64 I'm running a simple addition program, I have
I keep getting an error "Undefined symbols for architecturex86_64" & "ld: symbol(s) not found for architecture x86_64"
I'm running a simple addition program, I have 3 files: "add.h","add.cpp", "main.cpp"
This is my header file:
___________________
#pragma once
#include
int add(int x, int y);
___________________
Then my add.cpp file:
___________________
#include
using namespace std;
#include "add.h"
int add(int x, int y)
{
return x + y;
}
int main()
{
return 0;
}
___________________
And my main.cpp file:
___________________
#include
using namespace std;
#include "add.h"
int main()
{
cout << "3 + 4 =" << add(3,4) << endl;
return 0;
}
___________________
I can build my add.cpp successfully but my main.cpp filegives me the following error:
Undefined symbols for architecture x86_64:
"add(int, int)", referenced from:
_main in main-deee09.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to seeinvocation)
Build finished with error(s).
x-------x
I'm running it on Visual Studio on a mac, I did some researchand know that there is something wrong with my IDE, I just have noidea how to fix it.
Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started