Problems building for arm64 and x86_64 using cmake

I’m trying to build opencv libraries to use for a c++ project and it’s not outputting all the libs I need to build our project for both arm64 and x86_64 on macos.

I’m building OpenCV on an Arm Mac, which will then be used to build the final universal (arm64 & x86_64) binary of our project.

The options I’m using are as follows:

cmake -D CMAKE_C_FLAGS="-mmacosx-version-min=10.9" -D CMAKE_CXX_FLAGS="-mmacosx-version-min=10.9" -D CMAKE_OSX_ARCHITECTURES="x86_64;arm64" -D ONLY_ACTIVE_ARCH="NO" -DBUILD_LIST=dnn -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=OFF -DCMAKE_MACOS_DEPLOYMENT_TARGET=10.9 ..
make VERBOSE=1 -j4
make install

When run from the standard terminal this does not create opencv/build/install/lib/opencv4/3rdparty/lib/libippiw.a or libippicv.a

These files are a dependency of opencv required in order to build the x86_64 half of our system.

FWIW, building OpenCV via a when running a terminal under Rosetta 2 (with the exact same options) DOES make these libraries, but that’s a bit of a hack on our build system and I wonder if I’ll be missing other libs that only apply to arm64.

If anyone can spot a cmake option I’ve missed I’d be indebted to them, otherwise I’m guessing it’s a problem with OpenCV?

Thanks for any info,
Dave Elton

1 Like