skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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


  2. 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"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search