Jump to content

C++ Compiler Problems

- - - - -

  • Please log in to reply
10 replies to this topic

#1
Heartcubes

Heartcubes

    Newbie

  • Members
  • PipPip
  • 16 posts
I'm running on a Mac OS Leopard (10.5.8). I was able to download a dev kit from the Apple site which is the only one compatible with my system. The problem is the compiler doesn't work properly (so I assume). I tried compiling a simple C++ Hello World program and it gives me error messages. I believe I have GCC 4.0 if I'm not mistaken. I tried Google for answers but I haven't found any solution. Any form of help would be greatly appreciated. :)

Error message when I compile (using "gcc Hello.cpp -o Hello") in Terminal:


Undefined symbols:

  "___gxx_personality_v0", referenced from:

      ___gxx_personality_v0$non_lazy_ptr in ccJmKSqC.o

  "std::ios_base::Init::~Init()", referenced from:

      ___tcf_0 in ccJmKSqC.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 ccJmKSqC.o

  "std::ios_base::Init::Init()", referenced from:

      __static_initialization_and_destruction_0(int, int)in ccJmKSqC.o

  "std::cout", referenced from:

      __ZSt4cout$non_lazy_ptr in ccJmKSqC.o

ld: symbol(s) not found

collect2: ld returned 1 exit status



#2
AKMafia001

AKMafia001

    Programmer

  • Members
  • PipPipPipPip
  • 119 posts
Would you please post your code also?
I think i'm able to write a code for printing "Hello, World!". Proud of that!

#3
Heartcubes

Heartcubes

    Newbie

  • Members
  • PipPip
  • 16 posts
Here it is. I followed a book so I doubt the problem lies in the code though.

#include <iostream>


/*Hello::Hello() {

	// TODO Auto-generated constructor stub


}


Hello::~Hello() {

	// TODO Auto-generated destructor stub

}*/


int main(){

	std::cout << "Hello World!\n";

	return 0;

}


#4
AKMafia001

AKMafia001

    Programmer

  • Members
  • PipPipPipPip
  • 119 posts
Well! As you have commented the code:

/*Hello::Hello() {

	// TODO Auto-generated constructor stub


}


Hello::~Hello() {

	// TODO Auto-generated destructor stub

}*/


So, there doesn't seems any problem with it.

I guess, the problem is in,

Quote

gcc Hello.cpp -o Hello
.
You must use:

g++ Hello.cpp -o Hello


Hope this Helps!

Edited by AKMafia001, 12 January 2012 - 09:59 AM.
Typo!

I think i'm able to write a code for printing "Hello, World!". Proud of that!

#5
Heartcubes

Heartcubes

    Newbie

  • Members
  • PipPip
  • 16 posts
Thank you very much! I tried it but unfortunately the command doesn't exist. :(

#6
AKMafia001

AKMafia001

    Programmer

  • Members
  • PipPipPipPip
  • 119 posts
Maybe because it would not be installed. The installation would be quite simple. Try it.
I think i'm able to write a code for printing "Hello, World!". Proud of that!

#7
Heartcubes

Heartcubes

    Newbie

  • Members
  • PipPip
  • 16 posts
Is there a tutorial on how to do that?

#8
AKMafia001

AKMafia001

    Programmer

  • Members
  • PipPipPipPip
  • 119 posts
You can google it. Well! Why don't try Xcode on Mac?
I think i'm able to write a code for printing "Hello, World!". Proud of that!

#9
Heartcubes

Heartcubes

    Newbie

  • Members
  • PipPip
  • 16 posts
I already tried IDEs. Xcode and Eclipse won't run it either.

#10
breimer273

breimer273

    Newbie

  • Members
  • PipPip
  • 16 posts
I agree that you need to use g++ instead of gcc. I have the same OS and I installed the free version of Xcode (I believe it is the previous year's release) and g++ works for me. I would try to reinstall xcode since gcc and g++ should be included with xcode. Also, once you install Xcode, you would still compile and run the program in the terminal

#11
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
G++ is for C++ and GCC is for C.
Latinamne loqueris?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users