Go Back   XCode Forum- The iPhone and Mac OS Xcode Developer Community > Mac OS > Cocoa

Reply
 
LinkBack Thread Tools Display Modes

Building static and shared lib variants
  #1 (permalink)  
Old 10-22-2008, 05:29 AM
btietz btietz is offline
Junior Member
 
Join Date: Oct 2008
Location: San Diego, CA
Posts: 1
Default Building static and shared lib variants

I'm working on a C++ library. It's working great on Windows and Linux, and I bought a mac to start a port to MacOS X. Been playing with Xcode to get my feet wet. I don't think I can adopt the paradigm I want to but am hoping I'm wrong.

Philosophy:
A library can be built as static or shared. For any given application, it's up to the developer to decide which flavor makes the most sense, particularly so when the library is something new that may not yet merit shared library status, so to speak.

Based on this philosophy, take the windows project setup for example. The library doesn't have the classic Debug/Release confiiguration pair, but rather four configurations: DLLDebug, DLLRelease, LibDebug, LibRelease. The core library project has two targets: the library, and the unit test application. If the DLLDebug configuration is selected, building the unit test application has a dependency on and links against the debug shared library. On the other hand, if the LibRelease configuration is selected, the unit test app depends on and links against the release static library. There are two more permutations of course.

Is such an approach feasible? Playing with the configurations in XCode, it looks like I can create the four configurations, but the dependencies can't be isolated on a per-configuration basis.

Dependencies are just the start of it. The executable must link against a static or shared library, and it looks like for a given target, regardless of configuration, there's no way to set "Link Binary With Libraries" on a per-configuration basis. It looks like I can add MyLib.dylib or MyLib.a, but that would apply to the app for all configurations, with the Debug/Release distinction being automatic.

Next, there's the target itself. Ideally, I'd want a MyLib target, and whether the actual target is Debug/MyLib.dylib, Debug/MyLib.a, Release/MyLib.dylib or Release/MyLib.a would depend on what configuration is selected. Right now it looks like the only way to do this is to have a dynamic lib target and a separate shared lib terget (two separate targets). Not a huge deal, except that the list of source files for the two targets (Compiled Sources folder) would end up being identical but have to be maintained in parallel manually. It would be nice to have a single target with four configurations rather than two targets and two configurations.

Lastly, there's the build output folder. If I build an app and a library, they show up in build/Debug or build/Release. Not a big deal on the surface: Debug/MyLib.dylib and Debug/MyLib.a can coexist in the same folder. But the dynamic and shared flavors of application can't coexist in Debug and likewise for Release. It would be nice if the output folder could diverge into DynDebug, DynRelease, LibDebug, and LibRelease, with both application and library targets appearing in the correct folder. And the link-time dependency for the application would go along with the configuration.

Is there a way to set up an XCode project to generate outputs as I've described?

Thanks,
Brian
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump



All times are GMT. The time now is 08:50 PM.


vBulletin skin developed by: eXtremepixels
Powered by vBulletin® Version 3.8.0 Beta 1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27