C++ code not working

I was trying to run some c++ code on clang (I have command line tools installed) but it just showed this error: Undefined symbols for architecture arm64: then it showed bunch of random gibberish here is my code:

#include <iostream>
#include <vector>
using namespace std;
typedef std::string type_t;
int main(){
       type_t name = "Yashar";
       cout << "Hello " << name << '\n';
       return 0;
}

Tell us the exact command you used, and show us the “jibberish”; it might means something to us!

For context, your code builds and runs just fine on my Mac:

% cat main.cpp 
#include <iostream>
#include <vector>
using namespace std;
typedef std::string type_t;
int main(){
       type_t name = "Yashar";
       cout << "Hello " << name << '\n';
       return 0;
}
% clang++ main.cpp 
% ./a.out 
Hello Yashar

This is on macOS 14.3.1 with Xcode 15.3 selected as my command-line tools.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

C++ code not working
 
 
Q