title: MAC address from interface on OS X (C)
body: <p>This might be a stupid question and I apologize if it's already been addressed here, but I've searched quite a bit without much luck. I'm trying to get my interface's hardware address in C and I'm using OS X (x86-64). I know how to get it with <code>ifconfig</code>, but I want my program to get it automatically for any computer, well, at least OS X computers. I found another thread that posted this <a href="https://developer.apple.com/library/mac/#samplecode/GetPrimaryMACAddress/Listings/GetPrimaryMACAddress_GetPrimaryMACAddress_c.html#//apple_ref/doc/uid/DTS10000698-GetPrimaryMACAddress_GetPrimaryMACAddress_c-DontLinkElementID_3" rel="noreferrer">link</a> which pretty much does what I want (with some modifications), but I can't make the <code>iokit</code> functions link in <code>ld</code> (my compiler is <code>gcc</code>). I tried adding the flags <code>-lIOKit</code> and <code>-framework IOKit</code> to the <code>gcc</code> command line, but I still get the same link errors. Here's a link to my code: <a href="http://pastebin.com/bhF4U6Pc" rel="noreferrer">header</a> and <a href="http://pastebin.com/82CQbwKA" rel="noreferrer">source</a>.</p>