What is the proper way to build for macOS-x86_64 using cmake on Apple M1 (arm)?

  apple-silicon, c++, cmake, cross-compiling, linker

I’m using a library that I cannot compile for Apple M1, so I have decided to compile it and use it using (Rosetta 2) for x86_64 which I successfully did following this to install brew and clang for x86_64.

However when I compile my project and try to link it against this library I get this error:

ld: warning: ignoring file ..../libapronxx.a, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
...
ld: symbol(s) not found for architecture arm64

I have tried to the set compiler and linker flags ("-arch x86_64") but still got the same problem.

My question is: What is the proper way to build for macOS-x86_64 using cmake on Apple M1 (arm)?

Additional information: I’m using cmake via CLion.

Source: Windows Questions C++

LEAVE A COMMENT