2019-10-04

GCC 32bit compile on Mac

  • The i386 architecture is deprecated for macOS
    $ gcc -m32 fib.c
    ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
    ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
    Undefined symbols for architecture i386:
      "_printf", referenced from:
          _main in fib-68f6b9.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
  • Install i386 support
    $ sudo rm -rf /Library/Developer/CommandLineTools
    $ xcode-select --install
    $ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
    
  • Compile
    $ gcc -m32 fib.c
    ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
    
    $ make CFLAGS="-m32" fib
    cc -m32    fib.c   -o fib
    ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
    

No comments:

Post a Comment