Recent

Author Topic: trying to compile 32bit on 64bit OSX. Linker Error  (Read 3503 times)

Key-Real

  • New Member
  • *
  • Posts: 21
trying to compile 32bit on 64bit OSX. Linker Error
« on: May 02, 2021, 07:30:54 pm »
Im trink to comple as 32bit, but I get linker error:








Linking test
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: warning: ignoring file /System/Library/Frameworks//Foundation.framework/Foundation, building for macOS-i386 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation, missing required architecture i386 in file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation (2 slices)
ld: warning: ignoring file /System/Library/Frameworks//Cocoa.framework/Cocoa, building for macOS-i386 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /System/Library/Frameworks//QuartzCore.framework/QuartzCore, building for macOS-i386 but attempting to link with file built for macOS-x86_64ld: warning: ignoring file /System/Library/Frameworks//CoreData.framework/CoreData, missing required architecture i386 in file /System/Library/Frameworks//CoreData.framework/CoreData (2 slices)

ld: warning: ignoring file /System/Library/Frameworks//Carbon.framework/Carbon, building for macOS-i386 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /System/Library/Frameworks//AppKit.framework/AppKit, building for macOS-i386 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture i386:
  ".objc_class_name_NSApplication", referenced from:
      .objc_class_name_TCocoaApp in vipgfx.o
  ".objc_class_name_NSAutoreleasePool", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSBundle", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
      pointer-to-literal-objc-class-name in CocoaAll.o
  ".objc_class_name_NSFileManager", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSMenu", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSMenuItem", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSNotificationCenter", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSOpenGLContext", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSOpenGLPixelFormat", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSProcessInfo", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSScreen", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSTrackingArea", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSURL", referenced from:
      pointer-to-literal-objc-class-name in vipgfx.o
  ".objc_class_name_NSView", referenced from:
      .objc_class_name_TOpenGLView in vipgfx.o
  ".objc_class_name_NSWindow", referenced from:
      .objc_class_name_TBorderlessWindow in vipgfx.o
  "_CFBundleCopyLocalizedString", referenced from:
      _MACOSALL_$$_CFCOPYLOCALIZEDSTRING$CFSTRINGREF$PCHAR$$CFSTRINGREF in MacOSAll.o
      _MACOSALL_$$_CFCOPYLOCALIZEDSTRINGFROMTABLE$CFSTRINGREF$CFSTRINGREF$PCHAR$$CFSTRINGREF in MacOSAll.o
      _MACOSALL_$$_CFCOPYLOCALIZEDSTRINGFROMTABLEINBUNDLE$crc9C35D2E2 in MacOSAll.o
      _MACOSALL_$$_CFCOPYLOCALIZEDSTRINGWITHDEFAULTVALUE$crc26953C69 in MacOSAll.o
  "_CFBundleGetMainBundle", referenced from:
      _MACOSALL_$$_CFCOPYLOCALIZEDSTRING$CFSTRINGREF$PCHAR$$CFSTRINGREF in MacOSAll.o
      _MACOSALL_$$_CFCOPYLOCALIZEDSTRINGFROMTABLE$CFSTRINGREF$CFSTRINGREF$PCHAR$$CFSTRINGREF in MacOSAll.o
  "_CFRelease", referenced from:
      _TOOLS_$$_MAKEMESSAGE$ANSISTRING in tools.o
  "_CFStringCreateWithPascalString", referenced from:
      _TOOLS_$$_MAKEMESSAGE$ANSISTRING in tools.o
  "_CFUUIDGetConstantUUIDWithBytes", referenced from:
      _MACOSALL_$$_IUNKNOWNUUID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDEXTERNALDATASTORETYPEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDEXTERNALDATASTORESTOREINTERFACEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDIMPORTERTYPEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDIMPORTERINTERFACEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDEXPORTERINTERFACEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDIMPORTERURLINTERFACEID$$CFUUIDREF in MacOSAll.o
      ...
  "_CFUserNotificationDisplayAlert", referenced from:
      _TOOLS_$$_MAKEMESSAGE$ANSISTRING in tools.o
  "_GetItemCmd", referenced from:
      _MACOSALL_$$_GETITEMCMD$MENUREF$WORD$CHAR in MacOSAll.o
  "_GetItemMark", referenced from:
      _MACOSALL_$$_GETITEMMARK$MENUREF$WORD$CHAR in MacOSAll.o
  "_GetKeys", referenced from:
      _MACOSALL_$$_GETKEYS$KEYMAP in MacOSAll.o
  "_NSApp", referenced from:
      _VIPGFX_$$_COCOA_POLLEVENTS in vipgfx.o
      _VIPGFX_$$_SETUPMAINMENU in vipgfx.o
      _VIPGFX$_$SETUPMAINMENU_$$_ADDMENU$NSMENU in vipgfx.o
      _VIPGFX_$$_COCOA_INIT$$BOOLEAN in vipgfx.o
  "_NSApplicationDidChangeScreenParametersNotification", referenced from:
      -[TBorderlessWindow initWithContentRect:styleMask:backing:defer:] in vipgfx.o
  "_NSDefaultRunLoopMode", referenced from:
      -[TCocoaApp poll] in vipgfx.o
  "_NSViewGlobalFrameDidChangeNotification", referenced from:
      -[TOpenGLView initWithFrame:] in vipgfx.o
  "_TickCount", referenced from:
      _VIPGFX_$$_GETTICKCOUNT$$LONGWORD in vipgfx.o
  "___CFStringMakeConstantString", referenced from:
      _COCOAALL_$$_NSSTR$PCHAR$$NSSTRING in CocoaAll.o
      _COCOAALL_$$_NSSTR$ANSISTRING$$NSSTRING in CocoaAll.o
  "_kCFAllocatorDefault", referenced from:
      _MACOSALL_$$_KMDEXTERNALDATASTORETYPEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDEXTERNALDATASTORESTOREINTERFACEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDIMPORTERTYPEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDIMPORTERINTERFACEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDEXPORTERINTERFACEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KMDIMPORTERURLINTERFACEID$$CFUUIDREF in MacOSAll.o
      _MACOSALL_$$_KQLGENERATORTYPEID$$CFUUIDREF in MacOSAll.o
      ...
ld: symbol(s) not found for architecture i386
Error: Error while linking
Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 899
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #1 on: May 02, 2021, 08:06:17 pm »
macOS 10.15 and later no longer include 32 bit Intel libraries. If you wish to compile a 32 bit Intel application on such a system, you have to manually install a 32 bit SDK somewhere and point the compiler to it with the -XR command line option.

Someone created a github repository that contains most Mac OS X/OS X/macOS SDKs ever released: https://github.com/phracker/MacOSX-SDKs/ . If you don't want to clone the entire repository, you can try making a partial clone. Alternatively, you can create a full clone and then perform a partial checkout.

geraldholdsworth

  • Jr. Member
  • **
  • Posts: 95
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #2 on: May 08, 2021, 04:30:26 pm »
I'm in the same boat, having just upgraded to Catalina.

I've downloaded the SDKs, specifically the one for High Sierra, but now haven't got a clue what to do with it. The instructions are rather vague as to where to put this, and how to get Lazarus to see it (along with the 64 bit ones).

A nice simple step-by-step instructions would be nice, for simple folk like me.

In the meanwhile, I've got a MacBook Air with High Sierra on, but I needed to install Xcode on that - finding an old version that would install was the hardest...so that is currently downloading. And I've also trying to install Mojave in a VirtualBox on this Mac, which is taking for ever (5 hours and counting, so far, and still hasn't got to the GUI yet!).

I'm beginning to wonder if it is all worth it - I mean, how many folk will actually use the 32 bit binary, after I compile it?

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 899
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #3 on: May 08, 2021, 05:02:01 pm »
I'm in the same boat, having just upgraded to Catalina.

I've downloaded the SDKs, specifically the one for High Sierra, but now haven't got a clue what to do with it. The instructions are rather vague as to where to put this, and how to get Lazarus to see it (along with the 64 bit ones).
1) You can put it anywhere.
2) Technically Lazarus doesn't care at all, it's the system's linker. To make FPC tell the linker where the SDK is, add the -XR/full/path/to/MacOSX10.something.something.sdk command line parameter to FPC (via Lazarus, if you're using it).

geraldholdsworth

  • Jr. Member
  • **
  • Posts: 95
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #4 on: May 08, 2021, 06:13:52 pm »
That simple?

Well, for me, not so. Where does one put the -XR/<path>?

After a bit of Internet searching, all I could find suggested adding
Code: Pascal  [Select][+][-]
  1. if TargetOS = 'darwin' then begin
  2.   UsageCustomOptions += ' -k-macosx_version_min -k10.5';
  3.   UsageCustomOptions += ' -XR/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/';
  4. end;

To Project Options->Custom Options, in the top box with macOS 32bit Build mode selected (which worked OK before I upgraded). I even tried in the bottom box with no luck. I also tried adding -XR/<path> to the end of the Compiler executable entry in Tools->Options->Environment->Files, but it didn't like the entry when I clicked on OK.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 899
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #5 on: May 08, 2021, 06:25:26 pm »
That simple?

Well, for me, not so. Where does one put the -XR/<path>?
Sorry, I never use Lazarus for compiling, only for editing and code navigation.

Quote
After a bit of Internet searching, all I could find suggested adding
Code: Pascal  [Select][+][-]
  1. if TargetOS = 'darwin' then begin
  2.   UsageCustomOptions += ' -k-macosx_version_min -k10.5';
  3.   UsageCustomOptions += ' -XR/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/';
  4. end;

To Project Options->Custom Options, in the top box with macOS 32bit Build mode selected (which worked OK before I upgraded). I even tried in the bottom box with no luck. I also tried adding -XR/<path> to the end of the Compiler executable entry in Tools->Options->Environment->Files, but it didn't like the entry when I clicked on OK.
I can't help you with this, but please never use "' -k-macosx_version_min -k10.5'". Use -WM10.5 instead.

geraldholdsworth

  • Jr. Member
  • **
  • Posts: 95
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #6 on: May 08, 2021, 08:11:25 pm »
I've found a couple of fpc.cfg files which contain a pointer to the SDK, so I changed them to point to the 10.13 one...didn't make a difference. :(

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 899
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #7 on: May 08, 2021, 08:44:42 pm »
Try adding it directly in the custom options box, i.e. just add your -XR parameter there without any if-check, quotes, or "UsageCustomOptions +=".

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1582
  • Former Delphi 1-7, 10.2 user
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #8 on: May 09, 2021, 01:15:13 am »
The only Mac computer in the last 15 years that could not run 64 bit applications was the 2006 Mac mini with Intel Core Solo processor. Do you really need to compile 32 bit applications?

If all else fails, there are options:

1) install a Virtual Machine of Mojave using either Parallels ($$) or VMware Fusion ($$ / free for personal use);
2) install Mojave on an external disk;
3) partition the system disk and install Mojave
Lazarus 2.3 2021-08-10 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.3 r65500 FPC 3.3.1 r49634 macOS 11.5.2 aarch64 Xcode 12.5.1
Lazarus 2.3 2021-08-11 FPC 3.2.2 FreeBSD 13.0 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

geraldholdsworth

  • Jr. Member
  • **
  • Posts: 95
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #9 on: May 09, 2021, 09:42:37 am »
Try adding it directly in the custom options box, i.e. just add your -XR parameter there without any if-check, quotes, or "UsageCustomOptions +=".
Yep, that did it. Thank you.

geraldholdsworth

  • Jr. Member
  • **
  • Posts: 95
Re: trying to compile 32bit on 64bit OSX. Linker Error
« Reply #10 on: May 09, 2021, 09:44:46 am »
The only Mac computer in the last 15 years that could not run 64 bit applications was the 2006 Mac mini with Intel Core Solo processor. Do you really need to compile 32 bit applications?
That was what I was wondering, if it was all worth the effort.
1) install a Virtual Machine of Mojave using either Parallels ($$) or VMware Fusion ($$ / free for personal use);
Tried that - took bloody ages and didn't get me anywhere, so I gave up when I found the other solution. I was also starting down the path of installing Lazarus onto our MacBook Air, running High Sierra.

 

TinyPortal © 2005-2018