# Using Mac OSX as Unix



## drhowarddrfine (Jun 28, 2012)

I've always wondered about those who use a Mac for Unix development. My son bought one last year and loves it but he's not a developer. I only use FreeBSD boxes but am curious if anyone does development for Unix applications or web applications on a Mac and/or with VMs. 

I'm considering building my own super-duper God box so I can run everything under the sun on one system instead of using multiple boxes as I do now. Other than surfing the web on my son's Mac, I've never touched one.

What are your experiences with this?


----------



## kr651129 (Jun 28, 2012)

You can develop Unix apps on Mac as long as you don't use their propitiatory cocoa.  OS X is POSIX compatible and you can use wxWidgets for the GUI.  There are a number of ways to do develop Unix applications of a Mac.  I've never done it, it's when you develop for Mac on Unix when things get tricky from my understanding?

Edit:
If you do build a God box and you plan on running OS X from my experience it's easier to buy a Mac and run FreeBSD in emulators/virtualbox-ose instead of the other way around.  I was able to get OS X running as a VM but I was not impressed with the performance and I had to jump through a lot of hoops.  So I'd say keep OS X as your primary and then let your FreeBSD access the network and it'll look like you have two servers.


----------



## drhowarddrfine (Jun 28, 2012)

kr651129 said:
			
		

> If you do build a God box and you plan on running OS X


To clear up any confusion, no, I am not planning on running OSX on my God box. I'm considering buying a Mac instead and developing applications on it.


----------



## SirDice (Jun 28, 2012)

You don't need much more than this: https://developer.apple.com/xcode/


----------



## Anonymous (Jun 28, 2012)

drhowarddrfine said:
			
		

> I've always wondered about those who use a Mac for Unix development...
> 
> What are your experiences with this?



I develop everything on Mac - for Mac, for FreeBSD, for Windows, and for the Web - only Linux is out.

I mostly agree to what kr651129 have said - except that I won't suggest wxWidgets for the GUI develepment. I use The Cocotron in Xcode for cross-plattform Cocoa-Development.

In general, my code contains only a few #if defined (__PLATFORM__) conditionals. For example my Cocoa/Cocotron-GUI-Application uses a common code base of about 25000 lines and contains only two minor platform specific sections. It uses common localized NIB-Files for all platforms, and all (cross-)compilation and debugging happens within Xcode on the Mac.

My FreeBSD non-GUI project has reached about 12000 lines in C, and I am actively developing on it on the Mac using Xcode4.3.3  for testing and debugging (64bit). For deployment on my FreeBSD-8.3 server (32bit) I svn update the source and run the FreeBSD Makefile. This code base contains only 1 platform specific conditional and glue-code for UUID generation. The following list of #includes which compiles unconditionally on both, Mac and FreeBSD, with either gcc-4.2 or clang-3.1, may support the view, that the Mac OS X userland is mostly BSD.


```
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <syslog.h>
#include <signal.h>
#include <pthread.h>
#include <netdb.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <openssl/md5.h>
#include <openssl/sha.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>

#include <postgres.h>
#include <catalog/pg_type.h>
#include <libpq-fe.h>
```

For ME, Xcode on Mac OS X is the perfect development environment, and in addition it is quite flexible using it for cross-platform development, including Web-HTML/CGI/PHP. That said, I am well aware that many people do not like Xcode too much. For example vi addicts won't like it because it is too obvious how to quit the editor .

Comming back to your question. Yes, cross-platform development (including UNIX) on the Mac is perfectly possible. Whether you would like it, very much depends on how much comfortable you would become with Xcode. So, I suggest, that you have a closer look on Xocde on the Mac of your son before your final decision - if not already installed, Xcode can be installed for free from the Mac App Store. For shortening the learning curve, you might want to run through one of the various Xcode tutorials on the net.

While you are at the Mac of your son, have also a look into the terminal, and browse through the userland hierarchy, for finding out how similar everything is  here compared to the FreeBSD userland.

Best regards

Rolf


----------



## expl (Jun 28, 2012)

"Unix development" is a very vague statement. If you are dealing with general programs like for example dealing with databases, general data manipulation and just need general POSIX features then its enough. Just keep in mind that OSX libc and userworld are not the same as FreeBSD (even some people will tell you otherwise, they are wrong) and you will most likely will need to setup virtual environments to port your software or develop in pararel for different OSes. But that goes for mostly C/C++/Objective-C. OSX is a great environment for developing using interpreted languages like python/ruby as programs will run without modifications on all unix like systems (not like on windows).

I personally use OSX for most of my development (+virtualbox for porting) for over a year and personally prefer it over FreeBSD for a workstation. However I despise XCode and prefer to use Netbeans for all my coding.


----------



## kr651129 (Jun 28, 2012)

drhowarddrfine said:
			
		

> To clear up any confusion, no, I am not planning on running OSX on my God box. I'm considering buying a Mac instead and developing applications on it.



If you buy a Mac wouldn't you be running OS X? 

Another option, which isn't the best, but I've done in the past is to install a *BSD of your choice in emulators/virtualbox-ose and setup your workspace folder as a shared folder between your host OS and guest OS so you can code on your host then compile via ssh on you guest, and even test the application that way.


----------



## UNIXgod (Jun 28, 2012)

If you don't want to install xcode you can use this: https://github.com/kennethreitz/osx-gcc-installer

I used fink when Mac ports aka Darwin portswas in development. From there I used Darwin ports for many years. I experimented with gentoo prefix which was interesting. Today I use home brew and it's ok. None of these where perfect.


----------



## drhowarddrfine (Jun 28, 2012)

kr651129 said:
			
		

> If you buy a Mac wouldn't you be running OS X?


I keep confusing you. My God box would be one I put together and install FreeBSD on while running VMs for all the other stuff I want to run.

@rolfheinrich - it sounds like you are in a similar position to what I do. I never looked into XCode because I thought that was just for developing for Mac products. I would only be using vim and emacs and all the standard things most people use (cause I think assembly language is the only language anyone should use but C is OK.....and Lisp) :e .

So my thought was to do all the development I do now on the FreeBSD boxes but now do it on a Mac with FreeBSD and Linux in VMs and probably Windows, too. However everything I do, mostly C with Gimp, Inkscape, ssh, the basics, is in a term as much as I can so I'd like to keep it that way. 

My son is 320 miles away in Chicago so I don't see him often enough, or his system, though I will be there in September. 

This all sounds good. As a guy who used to design systems at the chip level, I have a special affection for building my own but I really love the Mac.


----------



## throAU (Jun 29, 2012)

The Mac gives you more options.

You also get the ability to do OS X and IOS apps if you feel like it, and it will run any PC operating system either natively or in a VM.


I used to build all my own systems too, but these days spec-sheet comparisons are pretty pointless.  If your criteria are "buy something 'fast enough' that doesn't feel like its made of cheese", the Mac fits the bill pretty well.


----------



## kr651129 (Jun 29, 2012)

I agree, I'm saving a Mac for just that reason.  I can install FreeBSD as a guest OS with guest additions and it'll run fine or even dual boot.  It will give way more development options, I've never been able to set up a OS X guest that was worth a damn.


----------

