How to compile for Mac OS X 10.5 - xcode

I'd like to compile my application for version 10.5 and forward. Ever since I upgraded to Snow Leopard and installed the latest XCode, gcc defaults to 10.6. I've tried -isysroot /Developer/SDKs/MacOSX10.5.sdk but that doesn't seem to work. Is there a GCC flag that allows me to set the SDK?
(Incidentally, I changed the gcc symbolic link to point to gcc-4.0 instead of gcc-4.2 and it worked but I thought I could tell the latest GCC to compile for an older SDK).
Thanks,
Rui

In XCode you only need to set the deployment target to OSX 10.5.
For gcc you need to set -mmacosx-version-min=10.5.

Related

Using GCC in -m32 mode on mac OS

I need to use gcc in -m32 mode on my macOS Mojave. I know it was deprecated some time ago. What should I do to make it possible?
You would need to download an older version of Xcode (eg. 9.x), and pre 10.14 SDK's (eg. 10.13), then try from there. Apple dropped Xcode capability/support for i386 in 10.14. In other words, Mojave can run existing 32-bit applications but can't build 32-bit applications anymore.
↳ MacPorts Discussion : User information about macOS Mojave
Works for me by installing:
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
as commented here: Can't compile C program on a Mac after upgrade to Mojave

Qt 5.4 - Mac OS X 10.6 Support

I compiled my App using Qt 5.3.2 on my Mac OS X 10.9 and it runs on Mac OS X 10.6 without any issue. But due to a bug in Qt 5.3.2 (unfixed) which causes the apps to crash on maximizing, if focus is on tree view, I had to switch to Qt 5.4.
After compiling my app using Qt 5.4 on Mac OS X 10.9, it no more runs on Mac OS X 10.6. It crashes with the error:
dyld: library not loaded: /usr/lib/libc++.1.dylib Qt
After some searching I figured out that
Running Qt apps on Mac OS X 10.6 is not supported by Qt 5.4 binaries available on Qt Website. A custom build is required for the same.
As per one source:
To make clang++ produce binaries compatible with g++ from llvm-gcc-4.2.1, use these compiler and linker flags: -stdlib=libstdc++ -mmacosx-version-min=10.6
These will make sure we link with the 10.6 CRT and that we do not link with libc++ (the default C++ library for clang++).
For custom build:
./configure -prefix $PWD/qtbase -opensource -no-c++11 -debug-and-release -nomake examples -nomake demos
10.6 is no longer supported in Qt 5.4
If you even compile it manually using -no-c++11, your app resulting executable will crash on 10.6
5.3.2 is the last to support 10.6 with -no-c++11

How can I update clang to 3.3 on Mac OS X 10.6

I'm running Mac OS X 10.6 and want to install TextMate 2, which is for Mac OS X 10.7+.
But all what it needs is a newer version of clang (LLVM), which is included in Lion and Mountain Lion. I read before here I can do that with MacPorts. So I used port install clang and MacPorts updated to clang-2.9, then clang-3.2 and finally clang-3.3. I thought, its updated now and I checked the version: clang --version. And it's not updated:
Apple clang version 2.0 (tags/Apple/clang-139) (based on LLVM 2.9svn)
Target: x86_64-apple-darwin10
Thread model: posix
So I copied the new clang file in this path (/opt/local/libexec/llvm-3.3/bin) to/usr/bin`. But now there's a fail :( :
dyld: Library not loaded: #executable_path/../lib/libLLVM-3.3svn.dylib
Referenced from: /usr/bin/clang
Reason: image not found Trace/BPT trap
The libLLVM-3.3svn.dylib is at /opt/local/libexec/llvm-3.3/lib. What can I do now, that
it runs clang-3.3? Sorry for my not perfect english ;) Thank you!
If you run clang from /usr/bin, it will be looking for the LLVM library in /usr/bin/../lib/libLLVM-3.3svn.dylib, i.e., /usr/lib/libLLVM-3.3svn.dylib (at least that's what the dynamic loader is telling you). You could try to copy the lib file into /usr/lib.
Alternatively, you can just download a more recent official build of Clang here:
http://llvm.org/releases/download.html
As far as I know, these builds are self-contained and do not need any dynamic libraries. However, it could be necessary to copy Apple's ARC libraries into a certain directory. If you run into trouble, please ask again.
Another approach is to build Clang and LLVM from source. You can find the repository URLs and instructions here:
http://clang.llvm.org/get_started.html
This should also build Clang with the LLVM libraries statically linked.
3.3, by the way, has not been officially released, so I would recommend using 3.2 unless you need any specific new features.

How can I compile a library in 32bit on a 64bit Mac machine (Mountain Lion)

I want to compile tesseract http://code.google.com/p/tesseract-ocr/ in 32bit on my Macbook. But I have a 64bit Mac OS Mountain Lion machine.
There is a Makefile, and I tried:
(1) $ ./configure --with-arch=i386
(2) $ $./configure --build=i386-apple-darwin --host=i386-apple-darwin --target=i386-apple-darwin
Both didn't work. The library compiled is still 64bit. Actually for (2) I see, after running the ./configure, it says somethings like "checking for i386-apple-darwin-g++ .. no", actually everything it checked for i386 had a "no" in the end. But the compilation succeed, just the library does not seem to be 32bit.
Anyone can help with this?
Try the -m32 to specify building 32-bit executables in the CFLAGS and CXXFLAGS. However, the MacOSX sdks for 10.7 and 10.8 don't have 32-bit i386 code to link against (only MacOSX10.6.sdk). I recommend using macports to install/build the tesseract engine on Mac OS X 10.7+.

How can I build Qt for OS X 10.5 on 10.6

I'm trying to build a static, universal Qt from source on Mac OS X 10.6 using the following command:
sh configure -static -opensource -universal
The problem, I have been told, is that PPC is not supported on 10.6 so I am getting many errors and the build eventually fails.
So I need to build for a different target version of OS X - 10.4 or 10.5. How can I do that? Do I need to add some parameters to my configure line and, if so, which ones?
Try using the -sdk option to configure. e.g.
./configure -sdk /Developer/SDKs/MacOSX10.5.sdk -opensource -universal
...if you want to make binaries targeting OSX 10.5 and later.
Statically linking is a separate issue again. I would not recommend it, especially since OSX already supports app bundles anyway, which I believe gives most of the same benefits to the end-user as static linking.

Resources