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

  • Home
  • SEARCH
  • 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 8779031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:40:42+00:00 2026-06-13T19:40:42+00:00

Should be straightforward, but when I compile the C++ Hello World code returns a

  • 0

Should be straightforward, but when I compile the C++ Hello World code returns a bunch of undefined symbol errors.

// my first program in C++
#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

Heres how I compile: Open terminal, cd to the directory, gcc hello.cpp

Then I get the errors. Any thoughts? I feel like I may have broken somehting… or I am just missing something really obvious. Any help is greatly appreciated!

Heres the errors:

Undefined symbols for architecture x86_64:
"std::cout", referenced from:
      _main in ccfUAf5i.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 ccfUAf5i.o
  "std::ios_base::Init::Init()", referenced from:
      __static_initialization_and_destruction_0(int, int)in ccfUAf5i.o
  "std::ios_base::Init::~Init()", referenced from:
      ___tcf_0 in ccfUAf5i.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
  • 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-06-13T19:40:44+00:00Added an answer on June 13, 2026 at 7:40 pm

    You need to use g++ to compile and link C++ code:

    g++ hello.cpp -o hello
    

    Or to be fully Stack Overflow compliant:

    g++ -W -Wall -Werror -pedantic -o hello hello.cpp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title is a bit long, but it should be pretty straightforward for someone
This should be a pretty straightforward question. I have the following code, which forms
This should be a pretty straightforward issue -- I'm trying to compile Lua (or
This should be straightforward but I'm getting tripped up on the line inside the
I'm trying to do something that I think should be pretty straightforward but I
I know this should be straightforward, but I am having problems splitting a data
I thought that this should be straightforward, but the result is puzzling me. When
It seems like this should be straightforward but I'm boggling. I've got my listview
This question should be quite straightforward, maybe stupid but I just can't find the
I think this should be straightforward, but with NHibernate simple things are always the

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.