Having issues with my compiler..

This is a discussion on Having issues with my compiler.. within the C++ Programming forums, part of the General Programming Boards category; Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ failed with exit code 1 How do I resolve this? I can't seem to find much on how ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    Having issues with my compiler..

    Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ failed with exit code 1

    How do I resolve this? I can't seem to find much on how to fix it on any site. ._.

    I'm on a Mac trying to use Xcode to compile some C++

    I've started off with the tutorial:
    C++ Tutorial - Introduction to C++ - Cprogramming.com


    And this was the code I used:

    Code:
    //
    //  HelloWorld.cpp
    //  Hello World
    //
    //  Created by on 26/02/12.
    //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
    //
    
    
    #include <iostream>
    
    
    usingnamespacestd;
    
    
    int main()
    {
    cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
        cin.get();
        
        return 1;
    }

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    >usingnamespacestd;
    using namespace std; with spaces.

    Other than that, if that is just a typo here, does the program show that after running? (possible...since you returned 1. Change it to return 0; and see what happens. )

    Also try compiling from the terminal and say the exact errors reported.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    I added the said spaces, that was a mistake with my copy + pasting.

    I tried compiling from terminal, and it came back with this:
    "Error: /usr/bin/xcode-select returned unexpected error."

    Does this help any?

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Compile with G++, if you do, it works (at least it did for me).

    Xcode is pretty much an IDE/wrapper of the GNU compilers.

  5. #5
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by memcpy View Post
    Xcode is pretty much an IDE/wrapper of the GNU compilers.
    About to be replaced by clang bacause apple can't switch to gpl(3) .
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  6. #6
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    -bash: g++: command not found

    Does Xcode not come with G++ as part of the download?
    Sorry, newbie here. ^^

  7. #7
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    Good news, managed to install Gcc. ^^

    Code:
    gcc -o HelloWorld HelloWorld.cpp
    Undefined symbols for architecture x86_64:
      "std::cout", referenced from:
          _main in cctzoxQw.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 cctzoxQw.o
      "std::cin", referenced from:
          _main in cctzoxQw.o
      "std::basic_istream<char, std::char_traits<char> >::get()", referenced from:
          _main in cctzoxQw.o
      "std::ios_base::Init::Init()", referenced from:
          __static_initialization_and_destruction_0(int, int)in cctzoxQw.o
      "std::ios_base::Init::~Init()", referenced from:
          ___tcf_0 in cctzoxQw.o
    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status
    Does this return anything interesting? ^^
    Last edited by SirFloofy; 02-26-2012 at 02:52 AM. Reason: Added [code]

  8. #8
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,616
    Those errors occur because you're not linking to the C++ library. Try using "g++" which does this automatically for you.
    Devoted my life to programming...

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Try g++ (not gcc) to compile c++ code.

    gcc is for C
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  10. #10
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    If the direct alias , g++ is not available, use this:
    "gcc -x c++ a.cpp -std=c++0x -lstdc++"
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,424
    Don't forget to include -Wall -Wextra and -pendantic, as well!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #12
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648
    What Elysia said, but -pedantic rather than -pendantic

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C and Cpp GCC Compiler Issues
    By Bangonkali in forum C Programming
    Replies: 15
    Last Post: 12-12-2010, 10:01 PM
  2. Compiler Issues
    By Adrian in forum Tech Board
    Replies: 10
    Last Post: 01-10-2008, 12:43 AM
  3. GNU C++ Compiler Issues!
    By code_writer in forum Tech Board
    Replies: 4
    Last Post: 05-12-2007, 11:03 AM
  4. Compiler Issues
    By marliwht in forum C Programming
    Replies: 6
    Last Post: 10-21-2005, 12:57 PM
  5. Compiler issues
    By Strix Varia in forum C++ Programming
    Replies: 3
    Last Post: 01-14-2005, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21