codeはこれ
#include
using namespace std;
int main()
{
cout
で出たエラーが。
$ gcc sample.cpp
Undefined symbols for architecture x86_64:
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccR2BuiH.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in ccR2BuiH.o
"std::cout", referenced from:
_main in ccR2BuiH.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
_main in ccR2BuiH.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
で、
$ gcc -lstdc++ sample.cpp
$ ls
a.out helloworld.cpp sample.cpp
$ ./a.out
ようこそC++へ!
C++をはじましょう!
これで解決した。