How do I compile Mac software?

15 Nov

So I noticed that this FlickrExport thing is actually open source, so I figured I could change it to point to 23hq.com myself. But I have no idea how to compile this bastard, and my Xcode ignores me when I tell it to open the files in FlickrExport.xcodeproj.

Can any of you Mac gurus out there (Mark, others?) tell me how to make it compile? Doesn’t OS X ship with everything needed to make software for it?

13 Responses to “How do I compile Mac software?”

  1. Guan Yang 15. Nov, 2005 at 9:00 pm #

    1) You need a newer version of Xcode.

    2) FlickrExport is open source, but it depends on the FlickrKit library, which isn’t. There are many instances of flickr.com’s hostname hardcorded in FlickrKit.

  2. Lars Pind 15. Nov, 2005 at 9:00 pm #

    Thanks, Guan.

    svn co http://speirs.org/svn/FlickrKit/trunk gets you FlickrKit.

    Downloading Xcode 2.2 — 2 hours 30 minutes to go.

  3. Lars Pind 15. Nov, 2005 at 9:00 pm #

    I have it *almost* working, but now I’m stuck.

    I managed to compile the thing, and even produce a .dmg with the installer. But then when I open iPhoto, it doesn’t work, and my console says this:

    <typo:code>
    2005-11-16 09:47:50.388 iPhoto[5638] *** -[NSBundle load]: Error loading code /Applications/iPhoto.app/Contents/PlugIns/FlickrExport.iPhotoExporter/Contents/MacOS/FlickrExport for bundle /Applications/iPhoto.app/Contents/PlugIns/FlickrExport.iPhotoExporter, error code 4 (link edit error code 4, error number 0 (Library not loaded: @executable_path/../Frameworks/Growl.framework/Versions/A/Growl
    Referenced from: /Applications/iPhoto.app/Contents/PlugIns/FlickrExport.iPhotoExporter/Contents/MacOS/FlickrExport
    Reason: image not found))
    2005-11-16 09:47:50.388 iPhoto[5638] Not a valid plugin: /Applications/iPhoto.app/Contents/PlugIns/FlickrExport.iPhotoExporter
    </typo:code>

    If I leave everything in the plugin, and just replace the FlickrExport with the one that Fraser does, then it works. Switch back to mine and it doesn’t.

    So it’s something about the linking that I can’t figure out. I’ve tried with both the precompiled growl SDK, and with a compile-from-scratch, same result.

    How can I see what libraries a binary links to? Anything else I can try? If you want me to help you get this setup on your machine, let me know, there was quite a bit of detective work in getting everything working this far.

  4. Lars Pind 15. Nov, 2005 at 9:00 pm #

    Guan helped me get to the next step.

    Here’s what otool -L says about mine:

    <typo:code>
    FlickrExport:
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
    @executable_path/../Frameworks/Growl.framework/Versions/A/Growl (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/FlickrKit.framework/Versions/A/FlickrKit (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.1.2)
    </typo:code>

    And here’s what it says about Fraser’s:

    <typo:code>
    FlickrExport:
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 11.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
    @executable_path/../PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/Growl.framework/Versions/A/Growl (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/FlickrKit.framework/Versions/A/FlickrKit (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.2.1)
    </typo:code>

    Note how @executable_path needs to be relative to iPhoto, not to the plugin. And note also how even I have the right path for FlickrKit, but not for Growl.

    How do I coerce Xcode into doing the right thing here?

  5. Mark Aufflick 15. Nov, 2005 at 9:00 pm #

    grr – sill Ajax posting thingamy crashed my firefox, so here goes again!

    I don’t know why the Growl link path doesn’t match the (correct) one for the FlikrKit framework, but you can manually solve the problem like so:

    <typo:code>PowerBook-G4$ otool -L FlickrExport
    FlickrExport:
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 9.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
    @executable_path/../Frameworks/Growl.framework/Versions/A/Growl (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/FlickrKit.framework/Versions/A/FlickrKit (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 47.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 71.1.3)

    PowerBook-G4$ install_name_tool -change @executable_path/../Frameworks/Growl.framework/Versions/A/Growl @executable_path/../PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/Growl.framework/Versions/A/Growl FlickrExport

    PowerBook-G4$ otool -L FlickrExport
    FlickrExport:
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 9.0.0)
    /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)
    @executable_path/../PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/Growl.framework/Versions/A/Growl (compatibility version 1.0.0, current version 1.0.0)
    @executable_path/../PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/FlickrKit.framework/Versions/A/FlickrKit (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 47.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 71.1.3)

    PowerBook-G4$</typo:code>

    the install_name_tool command is in my path as /usr/bin/install_name_tool.

    If you can’t figure out how to make Xcode/gcc link it right in the first place, I don’t see aproblem with adding this command to a script step in the build process.

    Hvad skal vi have til frokost?

  6. Lars Pind 15. Nov, 2005 at 9:00 pm #

    You rock! Thanks so much for figuring out how to solve this.

    Sorry about crashing your browser.

    Vi skal have sild!

  7. Lars Pind 15. Nov, 2005 at 9:00 pm #

    Here are some instructions I receieved straight from the horse’s mouth (Fraser):

    1. .xcodeproj files are only supported in (IIRC) Xcode 2.2 and later.

    2. You need to build your own version of Growl – the precompiled one has an incorrect (for our purposes) install path. You can:

    2.1 Check out a particular tag of Growl from svn. I usually pull the latest release (0.7.4 right now?)

    2.2 Open the Growl project and set the value of INSTALL_PATH for the Growl.framework target to:

    @executable_path/../Contents/PlugIns/FlickrExport.iPhotoExporter/Contents/Frameworks/

    3.Make sure the FlickrExport project references that framework (and make sure it gets copied into Frameworks/ in the Copy Files build phase.

  8. Matt Perreault 15. Nov, 2005 at 9:00 pm #

    I’ve been trying to compile FlickrExport 1.3.4 and I’m having the same problems with the Growl error thing… I really don’t know much about what I’m doing… Where do I find the Growl source if I need to compile my own version?

    Thanks!
    -Matt

  9. Matt Perreault 15. Nov, 2005 at 9:00 pm #

    I found the Growl Source… Now I’m trying to compile it for myself… which file do I change the target in??? I’m referring to what you describe in post #7…

  10. Lars Pind 15. Nov, 2005 at 9:00 pm #

    I never acually got around to compiling this, since right after Fraser told me about it, he released FlickrExport with 23 support himself. I’d switched to a new computer, and getting this all setup for compilation when normally I don’t do any Xcode stuff was just too painful. Sorry.

  11. Matt Perreault 15. Nov, 2005 at 9:00 pm #

    So far it’s like pulling teeth… :)

  12. Mike Purvis 15. Nov, 2005 at 9:00 pm #

    Hi everyone,

    I have a question about comment #3 above. I’ve recompiled Photon as a Universal binary for iPhoto 6, and it seems to be at least partially working, but there are aspects that are obviously failing silently.

    I’m just confused where you got "the console" from. I’m pretty new to OSX development, so it might be something obvious that I’m just missing. Is it just an error log somewhere that you’re tailing?

    Thanks!

  13. Mark Aufflick 15. Nov, 2005 at 9:00 pm #

    Hi Mike,

    Yes, the console is an app that shows you the standard console output. On a traditional Unix box, the console is a single serial terminal attached to the physical server.

    On MacOSX you will find an application that shows you not only the console output but also a whole load of crash logs etc.

    Go to the Utilities folder inside the Applications folder and you will find it.