Saturday air is steaming, my mind keeps spinning. I was frustrated to find out myself a chained slave trying to untangle a seemingly minor issue. Really, I am tired of incompatibility and unreadable docs.
My project lives on “libjpeg”, which should be built for i386 architecture, based on MacOSX.10.5.sdk
(why? Xcode insists to complain!). I wonder if there is already existing one to download for such a common library, but none is found.
Basic information about my env: I am on macOS Sierra 10.12.5 and Xcode defaults to MacOSX.10.11.sdk
. Its utility command lines can give you so,
xcodebuild -showsdks
The better bet would be to build libjpeg framework on my own. I came across a similar building process for iOS here, nice exemplary code to start off.
I cloned the earlier MacOSX SDKs here. In this case, I just need MacOSX.10.5.sdk
, to tell Xcode so, we set its env variable SDKROOT
:
export SDKROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk"
However at this stage it complains:
[MT] DVTSDK: Skipped SDK /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk; its version (10.5) is below required minimum (10.11) for the macosx platform.
Tweak the minimum version by
sudo vi /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist
modifying this key-string pair to
<key>MinimumSDKVersion</key><string>10.5</string>
To confirm it does now find this SDK, type
xcrun --sdk macosx10.5 --show-sdk-path
Finally, I tried to tune Pierre Dulac ’s iOS version to OSX. After some trial and error, I have the following:
To note that the script does build the framework successfully, however XCode still complains about object files during linking process.
ld: warning: object file (/Users/bo/Documents/dev/torcs-1.3.1/MacTorcs/Frameworks/libjpeg.framework/libjpeg(jcapimin.o)) was built for newer OSX version (10.12) than being linked (10.5)
To validate the architecture and info of object files, I’ve used the following,
otool -l path/to/built/libjpeg.a
lipo -info path/to/built/libjpeg.a
file path/to/built/libjpeg.a
I still couldn’t locate why my object files packed into libjpeg are built for 10.12. Anyone share the thoughts in the comments below?
References
- dreadful Apple doc on Xcode: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Chapters/xcode_8_0.html#//apple_ref/doc/uid/TP40004635-SW2
- xrun man page: http://www.manpagez.com/man/1/xcrun/
- tweak to use older SDKs: https://github.com/NixOS/nixpkgs/issues/9809
- Cross Compilation with clang: https://clang.llvm.org/docs/CrossCompilation.html