Public Group

# [Solved] Compiling on Terminal

This topic is 3404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello. I am very new to C++ programming here, and since my main focus will be games, decided to join Gamedev. I know a little C aswell as Actionscript (Flash's coding language). Due to the fact that I use a mac, I have installed XCode for the compiler & IDE, just to find out that when creating a c++ app, it needs about 10 additional files. Is there any way around this, so I can create a working c++ application that just outputs something in the terminal without all the files? I not, I have an other problem: When I try compiling a C application in the terminal, using
gcc [pathToFile ]

it compiles fine. However, when I do this with a c++ file, and dosen't compile, and gives me this error:
/usr/bin/ld: Undefined symbols:
std::ios_base::Init::Init()
std::ios_base::Init::~Init()
std::cout
std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
___gxx_personality_v0
collect2: ld returned 1 exit status

Anyone nows what I'm doing wrong? Thanks for all the help in advance. [Edited by - pseudobot on April 19, 2009 7:30:35 PM]

##### Share on other sites
I'm confused when you say "extra files" -- What extra files are you talking about?
If you want to just create a generic Xcode c++ project then you need to select other from the templates.
It'll make a default layout with no files in it. From there you simply need to only add a cpp file which automatically add a header. Do a simple hello world main. Then inside Targets create a new target and add the aforementioned cpp file to the target inside the compiled sources. This should automatically create an Executable which you can run. Youll have to launch the console to see the output -- you can do this from the run window. Aside from that a basic c++ app will build and execute in Xcode without any of the templates (cocoa/carbon/...).

Edit:
I did just notice that it will add the Carbon Framework as a pch, but it doesnt use it unless your project needs it. You can just pull it from the project settings and it should all still compile and work fine.

##### Share on other sites
Quote:
 I not, I have an other problem: When I try compiling a C application in the terminal, usinggcc [pathToFile ]it compiles fine. However, when I do this with a c++ file, and dosen't compile, and gives me this error:/usr/bin/ld: Undefined symbols:std::ios_base::Init::Init()std::ios_base::Init::~Init()std::coutstd::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)___gxx_personality_v0collect2: ld returned 1 exit statusAnyone nows what I'm doing wrong? Thanks for all the help in advance.
Try:
g++ [pathToFile]

##### Share on other sites
Thanks guys! Both ways work perfectly! :)
I never thought that I'd get replies like that so fast - thanks again guys!
:)

1. 1
2. 2
frob
16
3. 3
Rutin
12
4. 4
5. 5

• 13
• 12
• 59
• 14
• 15
• ### Forum Statistics

• Total Topics
632124
• Total Posts
3004243

×