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

weizilla

macrumors regular
Original poster
Feb 7, 2008
112
1
Is programming in C/C++ in OS X exactly the same as programming in Linux or are differences between C/C++ in Unix and Linux? I'm a graduate student and I need to develop a lot of tcp/ip sockets/posix programs for a linux computer (server and client internet communication applications using 802.11 wireless) and I'm wondering if it's cross compatible. I also need to use a compiler which compiles C/C++ programs to an ARM architecture. I have a compiler which I'm using in Ubuntu right now but I don't want to get a mac then have to put Ubuntu on it just to do my thesis work.
I would also want to do some C# development with some application framework stuff like with Spring so I'm also wondering if that's possible on a mac and how compatible the final code would be on a windows machine.

It's too bad I can't test things like this at the mac store and it doesn't seem like any of the sales people would know. I was thinking I could always buy a macbook and try it out but I know that once I have the computer in my hand, i won't return it even if I have to put linux on it :eek::)
 

Cromulent

macrumors 604
Oct 2, 2006
6,810
1,100
The Land of Hope and Glory
Well as long as you stick to cross platform libraries then it will be cross platform compatible. You'll need to recompile it though I would imagine.

As for the compiler, you can compile your own GNU cross compiler if you have the time to burn. I can't tell you how to do it because frankly, I got stuck; but it is possible.
 

mail4asim

macrumors member
Mar 7, 2007
50
24
Cincinnati, OH
Have you checked at the Apple Store. Some of them do have a programmer working who can answer your questions.
btw, like the other person stated, it all depends on if you're using cross-platform shared libraries. Like if you going to be writing a gui program, don't use Cocoa .. use wxWidgets, GTK or some other library which works on all platforms.
 

jsw

Moderator emeritus
Mar 16, 2004
22,910
44
Andover, MA
One other thing to consider is obtaining VMWare or Parallels and simply running Ubuntu virtually.
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
Mac OS X is part BSD, notably the networking stack. Porting applications, especially command line apps and server daemons, over from Linux/Unix over to Mac OS X is usually trivial.

In particular, Mac OS X comes with GCC as it's default compiler, just like Linux. There's the GNUARM toolchain for ARM compilation.

If you need a GUI front-end, you can use Qt which is available for Linux, Mac, and Windows. Qt also has a very nice networking API that's easier to program with than raw sockets.

You may have some luck with C# if you use Mono or dotGNU.
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
Also, if you want to port your programs, you should know that XCode also uses the GCC as compiler. So, compiling in other platforms is a matter of setting your compilation options.
 

x704

macrumors regular
Apr 15, 2006
118
0
C and C++ are in general, very cross-platform compatible, you can compile most any C or C++ program between linux, BSD, OSX, and Solaris with no problems... it may get annoying with the dependencys, but doable.

What is not cross compatible are the pre-compiled binaries without the source code. That is where windows losses it, they use things like directX, and other things where the source is not provided. OSX, Linux, and everyone else uses OpenGL for accelerated video.

Objective-C is different because it not used much outside of OSX... for Cocoa there is GNUstep, but its old, clunky, and annoying (so I hear). I do know a couple people that are working on a fork of GNUstep to fix up those problems and (eventually) provide a decent GUI lib, its called sidestep. I also know somebody working on GTK bindings for Objective-C (without needing Cocoa or *step).

So really you have to look into what you want to do and what libraries would best suit your needs.
 

weizilla

macrumors regular
Original poster
Feb 7, 2008
112
1
from the sounds of things, it seems like I shouldn't have any problems. All of my C/C++ programs are command line so I'm not worried about GUI or anything.

How compatible is mono and dotGNU with C#? or would it be better just to run a virtual version of windows and develop there?
 

Cromulent

macrumors 604
Oct 2, 2006
6,810
1,100
The Land of Hope and Glory
How compatible is mono and dotGNU with C#? or would it be better just to run a virtual version of windows and develop there?

From what I have read they are okay, but are missing a few important things. If you are just doing C# for fun then I am sure they are fine. If you are doing it more seriously run Windows.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.