|
#1
| |||
| |||
| I'm just starting to learn C++ and i need to know how to compile C++ programs in OS X. I've tried just typing: cc prog1.cpp in the terminal, but that doesn't work. I know it's not my code because it's straight out of my C++ book. Is there a way to do this in Project Builder? (yes i have the developer tools cd installed) Please be very specific...i'm new to UNIX and programming in general. Luckily the book i'm using seems pretty straightforward and so far just reading through it (can't compile...argh!!) i think i'm understanding most of it, so i'm really anxious to actually get something compiled to see if i'm actually understanding this stuff. Spaceman Spiff |
|
#2
| |||
| |||
| Compiling C++ gcc ain't MS Visual C++ so the source names should end either with cc or C (even though it may know cpp). However, to get correct runtime initialization, you have to compile with c++ testfile.cc which shoul result with a.out in the current directory. You can start it with ./a.out Resulting file can be renamed automatically, using c++ testfile.cc -o whatever and started with ./whatever |
|
#3
| |||
| |||
| Thanks alot! Now i can finally move past the first chapter without wondering if i'm really understanding or not. By the way i got the .cpp and cc testfile.cpp straight out of the book under the 'UNIX' instructions. Spaceman Spiff |
|
#4
| |||
| |||
| Project Builder is easy to use too. All you have to do is start a new project and when it asks for the type you select "C++ Tool". Then, you can just type all your stuff into the main.cpp and then click the build button. It will save the compiled program as the name of your project in your projects folder. You just drag that program to the terminal and run it. No problems at all.
__________________ PowerMac BW G4/500 (Rev 2 BW) -256MB RAM -ATI Rage 128 Powerbook G3/500 -256MB RAM Powermac 7500/440g3 -64MB RAM |
|
#5
| |||
| |||
| When I try When i try that it displays this message: ld: can't locate file for: -lcrt1.o Whats wrong |
|
#6
| ||||
| ||||
| Just a suggestion. If you are just learning to program and don't have much of a grasp of the command line tools, stay away from the IDEs like Project Builder/XCode. They will make it easier in some regards, but you will learn a lot more on the command line, at least while you are still getting started. |
|
#7
| ||||
| ||||
| what's wrong with filenames ending in ".cpp"?
__________________ mkwan UNIX was created in the late 1960s, in an effort to provide a multiuser, multitasking system for use by programmers. The philosophy behind the design of UNIX was to provide simple, yet powerful utilities that could be pieced together in a flexible manner to perform a wide variety of tasks. |
|
#8
| ||||
| ||||
| Quote:
|
![]() |
| Bookmarks |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Jaguar vs. Linux: Same code, different output!? | cyberkazoo | Software Programming & Web Scripting | 1 | February 25th, 2003 04:27 AM |
| compiling mesa libs on 10.2 | resglowing | Unix & X11 | 0 | December 3rd, 2002 01:11 PM |
| Compiling Java Source Code | RockyMorris | Software Programming & Web Scripting | 2 | May 23rd, 2002 01:17 PM |
| newbie: compiling c code | bluefossil | Mac OS X System & Mac Software | 6 | February 3rd, 2002 03:09 PM |
| code for posting graphics to thread post or guestbooks? | edX | Design & Media | 5 | December 17th, 2001 01:59 AM |