Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5966035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:44:03+00:00 2026-05-22T19:44:03+00:00

I am trying out a very simple cpp program on osx just to get

  • 0

I am trying out a very simple cpp program on osx just to get myself familiar with the osx platform, so I am very surprised to encounter any error message.

Here is the code:

#include <iostream> 
using namespace std; 
int main() { 
  cout << "Hello, world!" << endl; 
  return 0; 
}

I compile it by running

gcc -Wall hello.cpp -o hello

Then I get this ‘undefined symbols’ message:

Undefined symbols:
  "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 ccA9oElQ.o
  "std::ios_base::Init::Init()", referenced from:
      __static_initialization_and_destruction_0(int, int)in ccA9oElQ.o
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccA9oElQ.o
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long) const", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccA9oElQ.o
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccA9oElQ.o
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccA9oElQ.o
  "___gxx_personality_v0", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccA9oElQ.o
      _main in ccA9oElQ.o
      ___tcf_0 in ccA9oElQ.o
      unsigned long const& std::min<unsigned long>(unsigned long const&, unsigned long const&)in ccA9oElQ.o
      __static_initialization_and_destruction_0(int, int)in ccA9oElQ.o
      global constructors keyed to mainin ccA9oElQ.o
      CIE in ccA9oElQ.o
  "std::ios_base::Init::~Init()", referenced from:
      ___tcf_0 in ccA9oElQ.o
  "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
      _main in ccA9oElQ.o
  "std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))", referenced from:
      _main in ccA9oElQ.o
  "std::cout", referenced from:
      _main in ccA9oElQ.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I do not know if it is related: I have both xcode 3 and xcode 4 installed on my MBP

Here is the version information:

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

System information

$ uname -a
Darwin mbp002.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:44:04+00:00Added an answer on May 22, 2026 at 7:44 pm

    Use g++ instead of gcc since you’re compiling a C++ program:

    g++ -Wall hello.cpp -o hello
    

    Alternatively, use clang++ since Apple haven’t updated GCC in a while and it’s unlikely they’ll ever update it:

    clang++ -Wall hello.cpp -o hello
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK. I'm starting out on Backbone.js, and trying to do some very simple things.
I would like to create a very simple image gallery. I am trying to
I'm trying a very simple process of adding a row to a GoogleDocs spreadsheet
I am trying to create a very simple page in my module using hook_menu()
I'm currently trying out db4o (the java version) and I pretty much like what
I'm trying out the following query: SELECT A,B,C FROM table WHERE field LIKE 'query%'
I am trying out the debugger built into Zend studio . It seems great!
I'm trying out ASP.NET MVC routing and have of course stumbled across a problem.
I'm thinking about trying out MVC later today for a new app we're starting
I'm trying out Linq for the first time and having a bit of difficult

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.