New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

a few really simple questions


Post Reply New Thread Subscribe

 
Thread Tools
mzimmers

 
Member Since: Aug 22, 2010
Posts: 10
mzimmers is on a distinguished road

mzimmers is offline
Hi, all

After a departure from software development of almost 20 years, I'm wading back in. (I'm going to be writing simulators and UIs for dedicated processors.) In addition to needing to learn C++, I need to refresh my skills with the development tools.

I have a few questions which I'm sure are going to seem incredibly lame:

1. I found a C++ version of hello world. When I try to compile it, I get a bunch of error messages:

Code:
Undefined symbols:
  "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 ccFTxGWv.o
  "std::ios_base::Init::Init()", referenced from:
      __static_initialization_and_destruction_0(int, int)in ccFTxGWv.o
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccFTxGWv.o
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long) const", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccFTxGWv.o
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccFTxGWv.o
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccFTxGWv.o
  "___gxx_personality_v0", referenced from:
      std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccFTxGWv.o
      _main in ccFTxGWv.o
      ___tcf_0 in ccFTxGWv.o
      unsigned long const& std::min<unsigned long>(unsigned long const&, unsigned long const&)in ccFTxGWv.o
      __static_initialization_and_destruction_0(int, int)in ccFTxGWv.o
      global constructors keyed to mainin ccFTxGWv.o
      CIE in ccFTxGWv.o
  "std::ios_base::Init::~Init()", referenced from:
      ___tcf_0 in ccFTxGWv.o
  "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
      _main in ccFTxGWv.o
  "std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))", referenced from:
      _main in ccFTxGWv.o
  "std::cout", referenced from:
      _main in ccFTxGWv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
The same command works fine on a C file, so I assume I'm misusing the command. Can someone help?

2. How does one link? I simply don't remember.

3. I'm trying to decide on a development environment. Does anyone have an opinion on Eclipse? I downloaded it and started playing with it, but at first glance, it looks like more than I need for a single-person project with what I expect to be relatively modest development requirements. I'm going to look at XCode, too, but I'm considering just working within the terminal window.

Thanks for helping me scrape some of the rust off.
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
Posting the source may help.

1. Check this thread regarding problem 1. Search for namespace in that thread.

2. man ld
found via: man -k link

3. Can't really help except to say consider your end result; Is this OS X only or will you need to deploy on multiple platforms. Xcode will handle everything from low level system stuff up to complicated GUI stuff, but is directed OS X.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
mzimmers

 
Member Since: Aug 22, 2010
Posts: 10
mzimmers is on a distinguished road

mzimmers is offline
1. hmm...my .cpp file does have the "using namespace std;" line in it. Do I need to do anything on the command line other than just "gcc hello.cpp"?

2. OK, thanks...I'll look at the man pages (argh) a little later, once I get my compile errors/warnings resolved.

3. Oh, that's very good information. I won't be targeting the Mac platform at all, so I guess XCode is out of the question.

Thanks for the help.
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
I don't know C++ so don't have a definitive answer. Playing around I found that I had to use "g++ hello.cpp -o hello" to actually compile the code. You then run it via "./hello" if within that directory.

I thought gcc was capable of cross platform compiling. If so, then XCode might be usable.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
mzimmers

 
Member Since: Aug 22, 2010
Posts: 10
mzimmers is on a distinguished road

mzimmers is offline
Excellent! That "g++" command worked fine. It also produced an executable (which I wasn't expecting; back when I was coding, after we compiled, we had to run a linker to produce an executable). So, I gather that the gnu compiler is an "all in one" package?

How do you tell the shell to look in your current directory for an executable? I seem to remember something about a .login file in my home directory, but I can't remember the command.

Thanks.
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
I'm sure you'll need to learn about the linker. Don't assume that a single file with a main() function it acts the same as many different files compiled to be used in a larger app.

Look into the PATH shell variable for the shell you are running and which .login or .profile, or maybe .chsrc file name to use to set that up when you start the terminal. The default shell for OS X is now Bash.

The following Google search came up with some interesting links regarding the shell login stuff; "OS X" bash shell login script

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
pigoo3

 
pigoo3's Avatar
 
Member Since: May 20, 2008
Location: U.S.
Posts: 27,226
pigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond reputepigoo3 has a reputation beyond repute
Mac Specs: 13" MB 2.4ghz, 2gig ram, OS 10.7.5

pigoo3 is offline
I would suggest that you've chosen a really bad title...your questions are NOT "a few really simple questions"!

If they were "really simple"...you would probably be able to answer them yourself...and if they were "really simple" I and many others would probably be able to answer them. I have absolutely no experience programming in C++...so these are DEFINITELY not "simple questions"!

To me..."a few really simple questions would be":

- How do I turn on my Macintosh?
- How much does 1+1+1=?
- How many fingers does the average human have?
- What's heavier...10 pounds of feathers or 10 pounds of rocks?

Ha ha...just having a little fun? I think that a better title would be..."A few really hard questions!"...IMHO.

- Nixk

- Computer slow, too many "beachballs", read this: Beachballs
- Computer seems slower than it used to? Read this for some speedup tips: Speedup
- Almost full hard drive? Some solutions. Out of Space
- Apple Battery Info. Battery
QUOTE Thanks

Post Reply New Thread Subscribe


« OpenGL ES1 perspective with depth buffer fails. Square fails to render | Xcode refuses to launch after first launch. »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
A simple JavaScript calculator mraya Web Design and Hosting 9 02-23-2009 06:16 PM
Playing with pics on my Mac: Simple Questions. Pls help! :) MacNewbie Images, Graphic Design, and Digital Photography 4 10-27-2007 06:36 PM
simple Mac newbie questions thnx alien1980 OS X - Operating System 2 10-08-2007 01:52 PM
Many questions from xperienced Windows user just got a Mac :) Fedorov Apple Desktops 9 02-01-2006 08:09 PM
Newbie to Mac - probably simple questions mlc331 Apple Desktops 18 12-02-2005 10:41 AM

All times are GMT -4. The time now is 09:12 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?