Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Terminal/C++ Compiler



b) On "cpp -o Hi Hi.cc"and "cpp -g -o Hi Hi.cc" terminal hunged in there
(just the cursor blinks on a next line..) and after I killed the process

cpp is the "C pre-processor", and calling it merely preprocesses a C source file [ so there's a good reason this isn't producing any code for you :-) ] If you just do "cpp Hi.cc" you'll see this, too.

using Ctrl-D (twice!), the file named "Hi" was created and now files Hi

Try Ctrl-C when you want to kill processes...Ctrl-D is an end-of-line

c) On "c++ -o Hi Hi.cc" and "c++ -g -o Hi Hi.cc" reply was "Hi.cc:1:
iostream.h: No such file or directory"

The C++ course I had back in college stressed that you use "#include <iostream>" because the "standard" is for these files to come without ".h"
extensions. (CodeWarrior just has a dummy file for 'iostream.h' which includes 'iostream') Indeed, if you use that instead of "#include <iostream.h>" your example compiles and links (and runs) via the "c++" command variant. If you use "cc" to compile the program, you need to explicitly link to the C++ library:

cc -o Hi Hi.cc -lstdc++

-Jeff

------
Jeffrey Frey, Doctoral Candidate and Research Assistant
Doren Research Group
Dept. of Chemistry, University of Delaware
http://deaddog.duch.udel.edu/~frey/
_______________________________________________
darwinos-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwinos-users
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.