Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sean7512

macrumors 6502a
Original poster
Jun 8, 2005
856
41
I am a freshman, and my major is Computing and Info Science. I'm now in my second class of C++ programming. We use all Windows XP computers, with the Microsoft Visual Studio Compiler. All of our programs simply open in a DOS window. Is there any way that I can use my Mac for the homework and stuff, and still be able to compile and test it???
 

excalibur313

macrumors 6502a
Jun 7, 2003
780
5
Cambridge, MA
Sure! Just install Xcode that comes on the os x dvd. It is a really nice program that I like better than the c++ program that microsoft makes. You can use Xcode to program in all sorts of languages. It's quite wonderful!
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
Sure you can. All programs that are on OS X are typically made with xCode, which is in the DVD's that contain your system. It is free, and approx. 2gbytes.

In order to get yourself working, just install xCode, open it, and make a new project. In the dialog that appears that prompts you to select a king of application you want to make, select "C++ tool" and xCode do everything else for you.

You will soon discover that xCode is much better IDE than Microsoft's visual basic.
 

matix

macrumors member
Apr 24, 2005
33
0
Vancouver, BC
I'm a comp sci major taking C++ Programming II, and I've used Visual Studio, Xcode, and pico/nano/kwrite/command line.

Overall, Xcode is definitley my favorite. Terminal is 2nd. Visual Studio just has that Microsoft feel that I've learned to hate. I can't stand it.

Give Xcode a shot. I find that I can code the assignments 2-3X faster (no Reality Distortion Field here ;) ) because of the UI. I've found that the error messages and warnings are detailed and help me program better. (since 2.0)

My favorite is the unused variable warning. Our prof is pushing good memory practices big time.

But seriously, I would take issue with your school using XP boxes only. IMO Computer Science students should be learning on the command line (just like at my school). If all they are teaching is how to click a 'build' button then you might have a hard time picking up a unix system and building a more complicated program... just my 2c
 

Voidness

macrumors 6502a
Aug 2, 2005
847
65
Null
I'm in Computer Engineering, and I used Xcode 2 to program in C++ for all my assignments in the Data Structures course. There's just one strange thing I went through when copying my code to a Windows PC to get a Windows Executable file. Although the code that I wrote in Xcode and tested on a Mac would compile in Microsoft Visual C++, the result program would just act like crazy! But when I compile the same code in a GCC compiler on Windows, it works just like how worked on the Mac. I still didn't figure out the problem, especially that I'm only using standard C++ libraries.

Another thing that I would like to point out is when copying your code to a Windows PC, be sure to change the line ending format in Xcode ( Format > Line Endings > Windows ). If you don't do so, your code will not be displayed correctly on Windows.

( Wasn't this same question asked multiple times on this forum? )
 

darkwing

macrumors 65816
Jan 6, 2004
1,210
0
I'm 4 months away from an MS degree in computer science and have used my Mac throughout my college career. I use XCode for c++ and java assignments, and I use it for cross-building to x86 linux targets for work as well. You will be just fine as long as you don't get into the Windows specific API. When you take an OOP/GUI class it will most likely be done in Java, anyway. While Apple's java VM is a slow pathetic piece of utter crap compared to the Windows version that Sun invested so much time and money in, you will find everything made with it looks prettier and makes for excellent screenshots to turn in. :)

Good luck!
 

Sean7512

macrumors 6502a
Original poster
Jun 8, 2005
856
41
Compile (Build)

I have started a new project, and inside the "main.cpp" file that was started for me, I just copy and pasted a program that I had previously written. Now, how can I build it and run it? I can't seem to figure it out.
 

Josh

macrumors 68000
Mar 4, 2004
1,640
1
State College, PA
I'm in the exact same scenario. We write, compile, and run our programs on XP boxes.

I don't have XP or any form of Windows at home, so I asked my prof. what he is looking for us to hand in as assignments - the .cpp file, a screenshot/print out, or an .exe file), because I won't be using Windows, but OS X to do my homework.

I'll be using xCode for this, but I'm not opposed to GNU's compiler either - terminal use is just fine for me (lol working in transparent windows makes typing seem more fun to me...) :)

Anyway...the other day my prof. was talking about OS's, and to quote him shortly..."...Windows...Unix/Linux...and whatever monster they've got on Apple's these days."

Apparently the CS courses here - or perhaps just my prof - are very Windows-oriented. Definitely not what I'd like to see. I'm more interested in the proper code and theory than OS-specific projects :mad:

Oh well...new school next fall, so I'm looking forward to that.
 

Voidness

macrumors 6502a
Aug 2, 2005
847
65
Null
Sean7512 said:
I have started a new project, and inside the "main.cpp" file that was started for me, I just copy and pasted a program that I had previously written. Now, how can I build it and run it? I can't seem to figure it out.
If you're using Xcode 2, just click on the build icon located on the top toolbar in the project window. If you want to run it, just click on "Build and Go". You could also run your program from the terminal (after you build it in Xcode ofcourse).
 

Sean7512

macrumors 6502a
Original poster
Jun 8, 2005
856
41
Im using Xcode 1.1 I just used the "Installer" folder that was already on my harddrive. I prob have Xcode 2 at home on my Tiger DVD, correct? I keep getting erros with Xcode..I'll prob just wait until I get that DVD for the newer version.
 

Voidness

macrumors 6502a
Aug 2, 2005
847
65
Null
Yes, Xcode 2 is available on the Tiger DVD. I haven't worked withe Xcode 1, but it should be the same. What errors are you getting? How did you start a new project?
 

ChrisA

macrumors G5
Jan 5, 2006
12,904
2,143
Redondo Beach, California
Sean7512 said:
I am a freshman, and my major is Computing and Info Science. I'm now in my second class of C++ programming. We use all Windows XP computers, with the Microsoft Visual Studio Compiler. All of our programs simply open in a DOS window. Is there any way that I can use my Mac for the homework and stuff, and still be able to compile and test it???

I do this kind of stuf all day for a living. I started in the 70's. All of the IDEs I've seen have one problem in common: They lock you into one platform. So if you use MS Visual Studio You will have some effort if your code is to ever run on a non-MS platform. Of course "lock in" is the primary design goal of all MS software. Pretty much the same applies to Apple's xcode. Of course if you want to target ONLY one platform these IDE's work well.

I just use a terminal window, a text editor and somethimes a debugger. Or more accuratly many termial and text ediotr windows on several virtual screens. I'll use "make" as the build tool and lately I use GNU's "Autotools" (automake, autoconf and libtool) and I write with portibility in mind. It turns out that usful programs have a very long life, onger than any one platform.

With Java IDEs (like Eclipse) make sense but still a simple test editor works fine. I like "nedit" It does syntax hilighting, colum moves and macros and runs on _every_ platform under the sun. http://www.nedit.org/

Is this a four year university degree program? If so I'd expect them to offer only an introductory programming class and then go on to "data structures" or algorithm design or whatever. I think after the first class the proff didn't care what programing language we used for asignmants. I liked "PL/!" back then but.I remember using FORTRAN, LISP and various assembly languages too.

If they are only teaching c== on Windows it is really a disservice. They should be giving students a much wider experiance base including embeded micro processors (as found inside, say, a microwave oven or automobile) Perl scripting and bunch of other stuf.
 

therevolution

macrumors 6502
May 12, 2003
468
0
ChrisA said:
All of the IDEs I've seen have one problem in common: They lock you into one platform.

You mentioned Eclipse, yet you still think this? Eclipse is pretty much as far from single-platform lock-in as you can get. What's your reasoning?
 
ChrisA said:
I do this kind of stuf all day for a living. I started in the 70's. All of the IDEs I've seen have one problem in common: They lock you into one platform. So if you use MS Visual Studio You will have some effort if your code is to ever run on a non-MS platform....(cut)

Even changing compiler can be a significant problem, let alone IDE. Not just between compilers, but different versions of the same compiler can break compatibility. These problems will always be rife and the benefits (from a practical point of view) are only really reaped if the intention is to be as portable as possible, which should really be decided from the onset, otherwise there is a significant and unnecessary overhead involved, not forgetting the benefits that platform specific tools can bring.
 

Serac

macrumors newbie
Jan 26, 2006
4
0
I actually have the exact inverse problem, but I was wondering if anybody could please help me.

With a semester of c++, I have learned enough that I want to code at my house. At school we use macs and xcode, and I'm very accustomed to the interface. However, with windows at home, I'm wondering if anybody knows of an interface similar to xcode except for windows? I installed something wierd and I didn't get it at all, the least to say that I couldn't program.

I'd greatly appreciate it if anbody could help me. :)
 

Fender2112

macrumors 65816
Aug 11, 2002
1,141
402
Charlotte, NC
Serac said:
I actually have the exact inverse problem, but I was wondering if anybody could please help me.

With a semester of c++, I have learned enough that I want to code at my house. At school we use macs and xcode, and I'm very accustomed to the interface. However, with windows at home, I'm wondering if anybody knows of an interface similar to xcode except for windows? I installed something wierd and I didn't get it at all, the least to say that I couldn't program.

I'd greatly appreciate it if anbody could help me. :)

You could get a Mac Mini. :D
I also took a semester of C++ at a local community college. There we used Visual C++. It's not like Xcode but I guess it's the best Microsoft has to offer. It's not hard going back and forth with beginner type exercises. I kept all my source files on a USB flash drive and added them as needed to whatever project I was working in.
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
Borland allows their Foundation versions of Delphi, C++Builder, and JBuilder to be downloaded for free. The products are quite nice but they're not like Xcode and, in my experience, nothing else is.
 

Serac

macrumors newbie
Jan 26, 2006
4
0
Thanks for the advice, I want to be able to run programs like this:

//JE
//1/26/06
//Power function

#include <iostream.h>

int main()
{
int a, b, c;
cout<<"Give me a number";
cin>>a;
b=a*a;
cout<<"The power of your number is... "<<b<<endl;
}




Those programs would let me run and test stuff like this correct?
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
Serac said:
Thanks for the advice, I want to be able to run programs like this:

//JE
//1/26/06
//Power function

#include <iostream.h>

int main()
{
int a, b, c;
cout<<"Give me a number";
cin>>a;
b=a*a;
cout<<"The power of your number is... "<<b<<endl;
}




Those programs would let me run and test stuff like this correct?

They probably would, but you should correct it anyway.
 
Serac said:
Thanks for the advice, I want to be able to run programs like this:

//JE
//1/26/06
//Power function

#include <iostream.h>

int main()
{
int a, b, c;
cout<<"Give me a number";
cin>>a;
b=a*a;
cout<<"The power of your number is... "<<b<<endl;
}




Those programs would let me run and test stuff like this correct?
Uh, your C++ code isn't exactly the best and modern compilers will complain about lots of things.

First, with C++ there is no need for the ".h" in #include <iostream.h>, so you use #incluse <iostream> this applies to any class in the STL. You still need .h for others.

Second, the compiler will complain about the variable c being unused.

Third, related with #1... C++ has namespaces so all the STL stuff are under the std namespace, so you'd need to either declare "using namespace std;" or add the std:: scope before the cin and cout objects.

Finally, you can use the C math library by "#include <cmath>" and using the pow(double, double) function.

You don't need any of those programs, you can just install the Xcode tools and compile from the terminal.
 

Serac

macrumors newbie
Jan 26, 2006
4
0
right... it was just an example though. :p

I see now I didn't need b or c, I could have just done "a*=a;" or something. Thanks for the tips.

So I'm looking at the Dev program (I tried teh first program, but it was a hassle so i just quit! (It was so annoying, I had to install that program, but I needed the XP service pack 2, and then I couldn't get to that page because I needed internet explorer 5, then it wouldn't accept it when it was installing, all when everything was slow and then one thing made the whole computer restart and I had to go back and do the whole thing again, all to no useful end result... jeez, that's annoying.) and I think that may do it for me for my simple uses.... I want a beginner-friendly program, if it helps. :)

Also, is there any way to install mac os x on windows? I recall you could install windows/window stuff like microsoft word on a mac, is there a way to reverse it?
 

fuzzie

macrumors newbie
Jun 20, 2004
10
0
Serac said:
Also, is there any way to install mac os x on windows? I recall you could install windows/window stuff like microsoft word on a mac, is there a way to reverse it?

Word was a Mac program from the start, it's not 'windows stuff', sorry :) The Windows port is a rewrite.

You can emulate OS X on top of Windows with something like PearPC, but it's soooo slow. Maybe there will be progress on making the new Intel OS X versions work in vmware, like the development versions did, but that'd be running the whole OS.
 

sushi

Moderator emeritus
Jul 19, 2002
15,639
3
キャンプスワ&#
fuzzie said:
Word was a Mac program from the start, it's not 'windows stuff', sorry :) The Windows port is a rewrite.
Just a minor correction.

Word was for DOS first, then Mac, then Windows.

FWIW, Excel was Mac first, then Windows.
 

T-Stex

macrumors 6502
Jan 15, 2006
470
1
Pennsylvania
ChrisA said:
I just use a terminal window, a text editor and somethimes a debugger. Or more accuratly many termial and text ediotr windows on several virtual screens. I'll use "make" as the build tool and lately I use GNU's "Autotools" (automake, autoconf and libtool) and I write with portibility in mind. It turns out that usful programs have a very long life, onger than any one platform.

That's more what I'm used to. I'm in my Junior year as a Computer Science & Engineering student, and we've used the emacs text editor and a terminal window almost exclusively, on Linux machines. I'm glad that we do this, and like it better than using Visual Studio or CodeWarrior, which we did in high school.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.