Results 1 to 7 of 7
  1. #1
    a few really simple questions

    Member Since
    Aug 22, 2010
    Posts
    10
    a few really simple questions
    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.

  2. #2
    a few really simple questions
    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    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.

  3. #3
    a few really simple questions

    Member Since
    Aug 22, 2010
    Posts
    10
    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.

  4. #4
    a few really simple questions
    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    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.

  5. #5
    a few really simple questions

    Member Since
    Aug 22, 2010
    Posts
    10
    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.

  6. #6
    a few really simple questions
    xstep's Avatar
    Member Since
    Jun 25, 2005
    Location
    On the road
    Posts
    3,231
    Specs:
    2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
    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.

  7. #7
    a few really simple questions
    pigoo3's Avatar
    Member Since
    May 20, 2008
    Location
    U.S.
    Posts
    31,466
    Specs:
    2011 13" MBP 2.3ghz, 8gig ram, OS 10.7.5
    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
    - Too many "beachballs", read this: Beachballs
    - Computer seems slower than it used to? Read this for some slow computer tips: Speedup
    - Almost full hard drive? Some solutions. Out of Space
    - Apple Battery Info. Battery

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. A Few Simple Questions-
    By ElliottH in forum Running Windows (or anything else) on your Mac
    Replies: 4
    Last Post: 06-24-2010, 08:25 AM
  2. Just a few simple questions
    By Carmen89 in forum Switcher Hangout
    Replies: 16
    Last Post: 09-23-2008, 05:45 AM
  3. A Few Simple Questions
    By 651 in forum OS X - Operating System
    Replies: 2
    Last Post: 04-11-2007, 08:54 AM
  4. A few simple questions
    By Mactime in forum Switcher Hangout
    Replies: 3
    Last Post: 01-08-2007, 03:01 PM
  5. Some simple questions!
    By CaptainStandish in forum Switcher Hangout
    Replies: 7
    Last Post: 02-19-2004, 10:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •