mardi 2 mai 2017

c++ error when compiling from terminal on mac

Trying to compile my program called main.cpp using the gcc main.cpp command to compile on my mac using terminal. I get the following error

undefined symbols for architecture x86_64: "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from: _main in main-db0d6c.o . . . Dwarf Exception Unwind Info (__eh_frame) in main-db0d6c.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

here is the program:

// Example program
#include <iostream>
#include <string>

int main()
{
   std::string name;
   std::cout << "What is your name? ";
   getline (std::cin, name);
   std::cout << "Hello, " << name << "!\n";
}

Any help is greatly appreciated, even pointing me in the right direction. I don't understand how to read this error message and would like to learn as well as get my basic program running.

Aucun commentaire:

Enregistrer un commentaire