0

I built FFTW on my Apple m1 computer. When I run lipo -info libfftw3.a (which is located in .libs/libfftw3.a). It says it is of architecture ARM64.

In my Xcode I set the build target to 10.11, for backward compatibility.

Now when I add the FFTW library into my Xcode project, it complains:

The linked library 'libfftw3.a' is missing one or more architectures required by this target: x86_64.

How can I solve this? Do I need to build the library in an Intel device and create a universal library with these two libraries together (using lipo) or what's the right way to solve this?

Kevin M. Mansour
  • 2,915
  • 6
  • 18
  • 35
Thinium
  • 171
  • 1
  • 14

2 Answers2

1

In order to build a static library for both Intel and Apple silicon archictures, I need to build FFTW for both arch individually and then make an universal library. Here is how I do it.

  1. Go to FFTW root folder

  2. Build for Intel arch

    ./configure --prefix=/path/to/build/folder/lib-intel CFLAGS="-arch x86_64 -mmacosx-version-min=10.11” make make install

  3. Build for arm64

    ./configure --prefix=/path/to/build/folder/lib-arm64 CFLAGS="-mmacosx-version-min=10.11” make make install

  4. Make an universal build

    lipo -create path/to/build/folder/lib-intel/libfftw3.a path/to/build/folder/lib-intel/libfftw3.a -output libfftw3_universal.a

  5. Include libfftw3_universal.a in the Xcode project

Thinium
  • 171
  • 1
  • 14
1

You can configure it also with this line and it will build x86_64 & arm64 binary.

./configure CFLAGS="-arch arm64 -arch x86_64 -mmacosx-version-min=11.0"
Flair
  • 2,609
  • 1
  • 29
  • 41
Viktor
  • 26
  • 1