Porting/Programming for OS X and Darwin.

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
jshriver
Posts: 1342
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Porting/Programming for OS X and Darwin.

Post by jshriver »

Since engines tend to be cli based and use WB/UCI and such. I've wondered, if you do not have a Mac, can you just download the latest version of Darwin, compile there and it'll work ok under full blow OS X users?

OS X is now x86 based, and looks like Darwin is still open source, or at least a couple groups trying to maintain a Darwin distro based on the Apple open source code.

Guess I'm just curious how pure Darwin via open source, compared to the commercial OS X (know OS X uses Darwin as it's under pinnings) but thought they closed it off after a certain point.

Did try one groups Darwin which is supposed to be equivalent to OS X Lion, and tossed it into a VMware VM. Seems to work great, but if I did port some of my code to it, and release it, would real OS X users be able to use it without a problem?

-Josh
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Porting/Programming for OS X and Darwin.

Post by jdart »

I have no direct experience with Darwin but from what I know I would not recommend it as a way to develop for Mac OS.

You can get Darwin source from Apple but I think their releases now are just snapshots of the OS layer that is in MacOS. There is little if any support for running Darwin as a standalone OS. If you want to do that, you probably want to look at the PureDarwin project (puredarwin.org). Maybe that is what you tried. There is binary compatibility but since Darwin lacks many libraries that come with Mac OS (and I think PureDarwin is using BSD for userspace libraries/apps), apps that rely on those may not seamlessly work on MacOS.

--Jon
User avatar
jshriver
Posts: 1342
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Re: Porting/Programming for OS X and Darwin.

Post by jshriver »

Actually yes, PureDawin is what I am using.

I am a LONG time Linux user (circa 1995) and admit, once OS X came out 2000'ish, it was perfect for me. Using Pink, I could keep and use all my Linux apps but with freaking awesome hardware and a great OS. So I still maintain my admiration for OS X... but sadly when that computer died.. I never went back.

In the end it was about cost...Ubuntu broke free and hit that GUI greatness and ease of use given it's apt-get/dpkg capabilities, and once OS X went x86 I really never felt a reason to revisit.

Well, till I wanted to port some of my code to the system.

I'm really a bit at a cross roads... because I have seen online semi-modified OS X versions that can work on VMware on any Intel-based machine... but again to be brunt it's pirated.... and if I were to toss the $$ and buy a legal copy of the OS not sure if it would even WORK under vmware... so only the modified seems to work, unless I want to buy a gen OS X box.

Is there a happy medium? Interested in using even paying for OS X so I can legally develop for it... but don't want to pay the Apple tax for a machine I will rarely use and only ssh into to make/gcc.

Would it be bad for "middle ground" pay for a legal license, and never use, and then download any of those VMWARE "OS X images"?

Damn I really feel like crap even posting this... but there seems like there is no middle ground.

-Josh
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Porting/Programming for OS X and Darwin.

Post by jdart »

If it were me, I'd just go to ebay and buy a used Intel Mac Mini. There are lots of them in the $100-$150 range.

--Jon
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Porting/Programming for OS X and Darwin.

Post by bob »

jshriver wrote:Actually yes, PureDawin is what I am using.

I am a LONG time Linux user (circa 1995) and admit, once OS X came out 2000'ish, it was perfect for me. Using Pink, I could keep and use all my Linux apps but with freaking awesome hardware and a great OS. So I still maintain my admiration for OS X... but sadly when that computer died.. I never went back.

In the end it was about cost...Ubuntu broke free and hit that GUI greatness and ease of use given it's apt-get/dpkg capabilities, and once OS X went x86 I really never felt a reason to revisit.

Well, till I wanted to port some of my code to the system.

I'm really a bit at a cross roads... because I have seen online semi-modified OS X versions that can work on VMware on any Intel-based machine... but again to be brunt it's pirated.... and if I were to toss the $$ and buy a legal copy of the OS not sure if it would even WORK under vmware... so only the modified seems to work, unless I want to buy a gen OS X box.

Is there a happy medium? Interested in using even paying for OS X so I can legally develop for it... but don't want to pay the Apple tax for a machine I will rarely use and only ssh into to make/gcc.

Would it be bad for "middle ground" pay for a legal license, and never use, and then download any of those VMWARE "OS X images"?

Damn I really feel like crap even posting this... but there seems like there is no middle ground.

-Josh
I'm not quite sure what your goal is, but I am developing Crafty on a macbook now, and have zero problems, other than I used macports to download and build the latest gcc compiler since the mac clang compiler won't compile Crafty correctly. Everything seems to work just fine, although I have not tried things like shmget() and such which do work fine under linux...

But the posix threads stuff certainly works perfectly.
User avatar
jshriver
Posts: 1342
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Re: Porting/Programming for OS X and Darwin.

Post by jshriver »

jdart wrote:If it were me, I'd just go to ebay and buy a used Intel Mac Mini. There are lots of them in the $100-$150 range.

--Jon
Thank you very much. Didn't know about these little boxes or that they could be had for so cheap. Wad seriously afraid that if I wanted to dev for os x it require several thousand dollar investment.
rtitle
Posts: 33
Joined: Wed Aug 14, 2013 7:23 pm

Re: Porting/Programming for OS X and Darwin.

Post by rtitle »

In the engine I am developing, the only OS-dependent code is the multithreading support. My engine started out Windows-only, and on Windows it uses CreateThread to start a thread for analysis of a sub-tree and WaitForMultipleObjects to wait for a child thread to complete its sub-tree search. When I ported my engine to Mac (I have a physical Mac, one of those really nice new MacAir's with a dual-core Haswell processor), I had to change this code to use pthread_create to create the threads. Emulating WaitForMultipleObjects with pthread calls is a bit tricky; you need to use a condition variable and pthread_cond_wait, but I got it working on Mac. Works on Linux now too, with the same source code as Mac, since both are UNIX-based. I'm thinking of converting my engine to use the new C++ 11 thread API so it'll be portable without requiring #ifdef's in the threading logic to ask what platform it is on.

Rich
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Porting/Programming for OS X and Darwin.

Post by jdart »

Apple sells refurbished ones too, although those tend to be newer so are more costly. They do have a warranty, though.

Note that the latest version of Apple dev tools (XCode) requires a current OS. If you don't want to upgrade the OS you will need to install an older, compatible version.

Apple is on an LLVM/clang compiler currently. It is functional but their platform compiler tends to lag official LLVM/clang releases quite a bit. Older XCode versions in particular may be on quite old compilers.

--Jon
rtitle
Posts: 33
Joined: Wed Aug 14, 2013 7:23 pm

Re: Porting/Programming for OS X and Darwin.

Post by rtitle »

You can obtain gcc for the Mac, but it's correct that clang (based on LLVM) is what Apple provides and supports as its default C/C++ compiler (also ObjectiveC, but your chess engine is probably not written in that language). Also, Apple's XCode development environment is nice. It uses clang as its compiler and provides debugging/etc support. It's comparable to Visual Studio, and it's free.
Rich
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Porting/Programming for OS X and Darwin.

Post by zullil »

jdart wrote: Apple is on an LLVM/clang compiler currently. It is functional but their platform compiler tends to lag official LLVM/clang releases quite a bit. Older XCode versions in particular may be on quite old compilers.

--Jon
But it's easy to install newer compilers, say via MacPorts.