Jump to content
  • Advertisement
Sign in to follow this  
pseudobot

[Solved] Compiling on Terminal

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Quote:
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.
Try:
g++ [pathToFile]

Share this post


Link to post
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!
:)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!