[CMake] find_library and mac os x SDKs

Michael Wild themiwi at gmail.com
Sat Mar 27 12:54:46 EDT 2010


On 27. Mar, 2010, at 16:53 , Simmons, Aaron wrote:

>> It is a common misconception that one needs to use the 10.4 SDK to
>> create an executable that is compatible with 10.4.  This is not so.
> 
> In most cases, you're right.  However, we're linking to the iconv library.  If we don't specify the 10.4 SDK via isysroot, it will link to the wrong version of libiconv.dylib and won't run on 10.4 with this error:
>    dyld: Library not loaded: /usr/lib/libiconv.2.dylib
>      Referenced from: <snip>
>      Reason: Incompatible library version: <snip> requires version 7.0.0 or later, but libiconv.2.dylib provides version 5.0.0
>    Trace/BPT trap
> 
> The problem can be seen by inspecting the exe with otool:
> 	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
> 
> But if we use the 10.4 sdk, otool shows that we get the right "compatibility version" of libiconv:
> 	/usr/lib/libiconv.2.dylib (compatibility version 5.0.0, current version 5.0.0)
> 	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
> 	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10)
> which will run fine on 10.4.
> 
> 
> Thanks,
> aaron

What I don't understand is this: Why do you want to force the SDK? Shouldn't this be the worry of the person doing the build?

If I download some open-source software and then build it for myself, I don't want to be forced in using the 10.4 SDK, I wan't to build against the greatest and latest! However, if I then want to distribute the software in binary form to as many people as possible, I'll just set the CMAKE_OSX_SYSROOT cache variable to /Developer/SDKs/MacOSX10.4u.sdk (and also specify -mmacosx-version-min=10.4 in all CMAKE_<LANG>_FLAGS variables).


Michael


More information about the CMake mailing list