Success: Natively built FLTK on ARM64 (Apple Silicon) macOS!

94 views
Skip to first unread message

fischer...@gmail.com

unread,
Nov 24, 2020, 9:57:53 AM11/24/20
to fltk.general
Just wanted to report that I successfully built 1.4.x (Build 20201120-aa140973) on my M1 MacBook Air natively. To compile FLTK, nothing special was needed:

    make clean
    ./configure --enable-localpng --enable-localzlib
    make

Using lipo shows that the compiled test applications are indeed built for ARM:

    sf@Air-von-Stefan test % lipo ./blocks -archs
    arm64

I used this FLTK build to statically build my (commercial) application and again used lipo to create the universal binary:

    lipo -create application-binary-arm application-binary-intel -output application-binary-fat

application-binary-fat then replaced the single architecture binary within the .app bundle created by my build script (a Bash file). Signing and notarizing the .app bundle was then straightforward as always.

Having received my M1 MacBook on Friday, I was already able to ship a universal binary for my application on Monday. So I want to thank all the FLTK developers for their great work!


Manolo

unread,
Nov 24, 2020, 1:01:08 PM11/24/20
to fltk.general
That's great news!

I'd like to express an alternative, simple way to obtain universal application bundles with configure/make :
./configure ARCHFLAGS="-arch x86_64 -arch arm64   -Xarch_x86_64 -mmacosx-version-min=10.13"
make
will build FLTK and all test apps as universal  apps.

Ian MacArthur

unread,
Nov 24, 2020, 5:19:31 PM11/24/20
to fltkg...@googlegroups.com
Indeed, great news.

I note the OP says the built natively on the M1, and it worked, but it was not clear to me if the fat-binary was created on the M1 ARM, or on the x86_64, or perhaps the two binaries were compiled natively then copied to one host for lips to do its magic?

It would be handy to know, I think.

Indeed, it would be handy to know if a fat-binary (including an arm M1 binary) can be built entirely on an x86_64 host, since that would go a long way to address the issues that David (w1hkj) is having I imagine.

I can’t test this myself (as far as I know) because my very newest Mac is now Too Old...


Greg Ercolano

unread,
Nov 24, 2020, 6:59:08 PM11/24/20
to fltkg...@googlegroups.com
On 2020-11-24 14:19, Ian MacArthur wrote:
>
> Indeed, it would be handy to know if a fat-binary (including an arm M1 binary) can be built entirely on an x86_64 host, since that would go a long way to address the issues that David (w1hkj) is having I imagine.
>
> I can’t test this myself (as far as I know) because my very newest Mac is now Too Old...


    As I recall correctly from the PowerPC days, we could build intel binaries on the older PPC platform if we installed the proper intel option to Xcode or whatever it was then. I built fat binaries for many years until it was obvious PPC was dead and gone, which pretty much happens the moment the web browsers start supporting it, and important websites stop supporting those old browsers.  X^D

Greg Ercolano

unread,
Nov 24, 2020, 7:48:55 PM11/24/20
to fltkg...@googlegroups.com
On 2020-11-24 15:59, Greg Ercolano wrote:
On 2020-11-24 14:19, Ian MacArthur wrote:
Indeed, it would be handy to know if a fat-binary (including an arm M1 binary) can be built entirely on an x86_64 host, since that would go a long way to address the issues that David (w1hkj) is having I imagine.
I can’t test this myself (as far as I know) because my very newest Mac is now Too Old...
    If I recall correctly from the PowerPC days, we could build intel binaries on the older PPC platform if we installed the proper intel Xcode options or whatever it was then. I built fat binaries for many years until it was obvious PPC was dead and gone, which pretty much happens the moment the web browsers stop supporting it, and important websites stop supporting those old browsers..

    Meh, I was in a rush with my reply above; small fixes for clarity in green..


fischer...@gmail.com

unread,
Nov 25, 2020, 4:58:24 AM11/25/20
to fltk.general
Thanks for the advice, I'll try to adopt my build process. I was just happy to have found a way that worked for me, so I stopped further investigations. :-)

fischer...@gmail.com

unread,
Nov 25, 2020, 6:08:47 AM11/25/20
to fltk.general
I note the OP says the built natively on the M1, and it worked, but it was not clear to me if the fat-binary was created on the M1 ARM, or on the x86_64, or perhaps the two binaries were compiled natively then copied to one host for lips to do its magic?

Some more details: I'm building two standalone application bundles, one on my Intel Mac running Catalina, the other on the ARM Mac. I then copy the binary from the app bundle (xxx.app/Contents/MacOS/) on the ARM Mac to the Intel Mac where I use lipo to create a universal binary as explained before. This universal binary is then placed in the app bundled, replacing the existing Intel binary. I then sign and notarize this app bundle.

 
Indeed, it would be handy to know if a fat-binary (including an arm M1 binary) can be built entirely on an x86_64 host, since that would go a long way to address the issues that David (w1hkj) is having I imagine.

As my Intel Mac is from 2012 and runs only Catalina, I haven't tried this. It should be possible as XCode 12.2 runs on Catalina, but I don't want to change my working scripts. You know: Never change a running system. :-)

Building on a single system would only save copying and pasting some simple command line commands, so I don't want to mess around with it.

imm

unread,
Nov 25, 2020, 6:47:12 AM11/25/20
to general fltk
On Wed, 25 Nov 2020, 11:08 fischerlaender wrote:


Some more details: I'm building two standalone application bundles, one on my Intel Mac running Catalina, the other on the ARM Mac. I then copy the binary from the app bundle (xxx.app/Contents/MacOS/) on the ARM Mac to the Intel Mac where I use lipo to create a universal binary as explained before. This universal binary is then placed in the app bundled, replacing the existing Intel binary. I then sign and notarize this app bundle.



Thanks for letting us know.
That's what I had inferred you were doing, from your earlier post, which is why I asked if you were building each binary natively...

If you have access to both architectures that may well be the easiest option.



Indeed, it would be handy to know if a fat-binary (including an arm M1 binary) can be built entirely on an x86_64 host, since that would go a long way to address the issues that David (w1hkj) is having I imagine.

As my Intel Mac is from 2012 and runs only Catalina, I haven't tried this. It should be possible as XCode 12.2 runs on Catalina, but I don't want to change my working scripts. You know: Never change a running system. :-)

Building on a single system would only save copying and pasting some simple command line commands, so I don't want to mess around with it.


Indeed so.
Though I've generally found Xcode to have pretty good compatibility across versions so it might go smoothly!

Really I was just wondering how well the fat-binary process would work for those who only have an Intel Mac at present.

Like me: but mine is Too Old (10.13) which I do not think can support a "recent enough" Xcode to even try...
-- 
Ian
From my Fairphone FP3

Manolo

unread,
Nov 27, 2020, 8:21:15 AM11/27/20
to fltk.general
On Wednesday, November 25, 2020 at 12:47:12 PM UTC+1 Ian MacArthur wrote:

Really I was just wondering how well the fat-binary process would work for those who only have an Intel Mac at present.
It's clearly my understanding that when Apple declares that Xcode12.2 allows to build Universal apps,
it means you can produce on an Intel Mac an app that will run natively on an ARM new Mac.
What I know for sure is that you can produce something that contains both architectures.


Like me: but mine is Too Old (10.13) which I do not think can support a "recent enough" Xcode to even try...
What is really required is "Command Line tools for Xcode 12.2" which may be compatible with older
units. Then, build with configure/make or with CMake/make.
Reply all
Reply to author
Forward
0 new messages