Correct settings for CMake to compile FLTK for Mac universal (target 10.13)

39 views
Skip to first unread message

Roberto Panetta

unread,
Jun 24, 2025, 11:50:49 AMJun 24
to fltk.general
Compiling FLTK 1.4.3 (June 2025) under macOS Sequoia 15.5 on Xcode 16.4 on a Mac mini M4 , if I compile using via terminal './configure; make' I obtain libraries that work well with macOs target 10.13 and $(ARCHS_STANDARD), but If I use CMake, (that in future will be the only way), I obtain libraries that give errors regarding the 'rgb8_neon'

I tried in Xcode -DPNG_ARM_NEON=0 in the CFlags but nothing..

What to select in CMake to obtain Universal Libraries that works well for both intel and arm?
 

Errors obtained by the libraries compiled with CMake
Undefined symbols for architecture arm64:
  "_fltk_png_do_expand_palette_rgb8_neon", referenced from:
      _png_do_expand_palette in libfltk_png.a[arm64][9](pngrtran.o)
  "_fltk_png_do_expand_palette_rgba8_neon", referenced from:
      _png_do_expand_palette in libfltk_png.a[arm64][9](pngrtran.o)
  "_fltk_png_init_filter_functions_neon", referenced from:
      _png_init_filter_functions in libfltk_png.a[arm64][10](pngrutil.o)
  "_fltk_png_riffle_palette_neon", referenced from:
      _fltk_png_do_read_transformations in libfltk_png.a[arm64][9](pngrtran.o)
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Gonzalo Garramuño

unread,
Jun 24, 2025, 12:01:39 PMJun 24
to Roberto Panetta, fltkg...@googlegroups.com

On 6/24/2025 12:50 PM, Roberto Panetta wrote:
>
> What to select in CMake to obtain Universal Libraries that works well
> for both intel and arm?

I recommend using CMake directly from the command-line instead of from
Xcode, but that's just me.  I am an old guy.

To support intel and arm, you should fill the -DCMAKE_OSX_ARCHITECTURES
with the two architectures you want to build for.  I have not yet tried
to do it myself, so you might have to dig into the cmake docs at cmake.org.

--
ggar...@gmail.com

Roberto Panetta

unread,
Jun 24, 2025, 2:43:28 PMJun 24
to fltk.general
Off course I use $(ARCHS_STANDARD), the problem is that the png fltk library doesn't compile correctly for the arch architecture (as example Fluid can't run).

Roberto Panetta

unread,
Jun 24, 2025, 3:06:31 PMJun 24
to fltk.general
to add more I tried to compile on a different Mac (this time Intel based) and same error, compiling for both, the arch architecture get the same error:
 errors: Undefined symbols for architecture arm64:

  "_fltk_png_do_expand_palette_rgb8_neon", referenced from:

      _png_do_expand_palette in libfltk_png.a(pngrtran.o)

  "_fltk_png_do_expand_palette_rgba8_neon", referenced from:

      _png_do_expand_palette in libfltk_png.a(pngrtran.o)

  "_fltk_png_init_filter_functions_neon", referenced from:

      _png_init_filter_functions in libfltk_png.a(pngrutil.o)

  "_fltk_png_riffle_palette_neon", referenced from:

      _fltk_png_do_read_transformations in libfltk_png.a(pngrtran.o)

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)


The intel parts seems compiles correctly



Gonzalo Garramuño

unread,
Jun 24, 2025, 4:36:32 PMJun 24
to fltkg...@googlegroups.com

On 6/24/2025 4:06 PM, Roberto Panetta wrote:
> to add more I tried to compile on a different Mac (this time Intel
> based) and same error, compiling for both, the arch architecture get
> the same error:

I am afraid I cannot help you as I don't own a mac arm64 yet. Not too
crazy about the name myself.  I prefer to call it aarch64.
Albrecht maintains the cmake build system and Matthias uses I believe
cmake from Xcode to compile fluid, so both can chime in if they want to.

--
ggar...@gmail.com

Manolo

unread,
Jun 25, 2025, 2:45:54 AMJun 25
to fltk.general
This command in a Terminal
   cmake   -B .   -S ..   -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"   -G Xcode
possibly adapted for the location of the build and the source directories in your settings
will produce FLTK.xcodeproj.
Then, open that project under Xcode and build whatever of its targets.
You'll obtain libraries and executables for both x86_64 and arm64 architectures

Alternatively, you can use the CMake macOS application and its GUI.
Select the source code and build directories.
Click "Configure".
Select the Xcode generator.
Select item "CMAKE_OSX_ARCHITECTURES" in the central panel and set it to     x86_64;arm64
Click "Configure" again.
Click "Generate".
You'll obtain the same FLTK.xcodeproj as above.



Roberto Panetta

unread,
Jun 25, 2025, 3:58:21 AMJun 25
to fltk.general
So the point is that $(ARCHS_STANDARD) CAN'T be used in Cmake and  'x86_64;arm64' _has to be used_ creating the libraries and in general compiling ALL for FLTK 1.4.3
Then for my final apps I can use it '$(ARCHS_STANDARD) ' linking the prebuilt libs to produce a universal binary

Super super thank you very much Manolo!

Manolo

unread,
Jun 25, 2025, 5:07:36 AMJun 25
to fltk.general
I forgot to add that you need to select the Release mode to obtain 2-architecture products.
The Debug mode produces products for the architecture of the running machine.

Reply all
Reply to author
Forward
0 new messages