MacOS libOMP not found with brew
This used to work, not sure what changed. CMake can't find libOMP on apple silicon clang. I added this :
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include")
set(OpenMP_C_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY "/opt/homebrew/opt/libomp/lib/libomp.dylib")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include")
set(OpenMP_CXX_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY "/opt/homebrew/opt/libomp/lib/libomp.dylib")
endif()
before searching for OpenMP and then the build is succeeding now. I got this snippet from here: https://github.com/stella-cv/stella_vslam/issues/578#issuecomment-2673184480
@lainy see above
I just tested on a brand new macos machine following the build instructions from the user manual and it built without any issues.
Can we close this ticket or are you still having problems?
I just tried a fresh build (not pull, clean clone) and hit the same issue again, so I don't think it's fixed unless I was supposed to pull a special branch.
Building on an M1 Air (2020 8GB).
Grab the repo with git clone --recursive, then make a build folder and run cmake .. to configure build :
-- The C compiler identification is AppleClang 17.0.0.17000013
-- The CXX compiler identification is AppleClang 17.0.0.17000013
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.39.5 (Apple Git-154)")
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "0.29.2")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
CMake Error at CMakeLists.txt:155 (message):
ngscopeclient requires OpenMP but your C++ compiler does not appear to
support it.
-- Configuring incomplete, errors occurred!
I do have OpenMP installed via brew. brew info libomp:
==> libomp: stable 20.1.7 (bottled) [keg-only]
LLVM's OpenMP runtime library
https://openmp.llvm.org/
Installed
/usr/local/Cellar/libomp/20.1.3 (9 files, 1.7MB)
Poured from bottle using the formulae.brew.sh API on 2025-04-29 at 23:23:32
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/lib/libomp.rb
License: MIT
==> Dependencies
Build: cmake ✘, lit ✘
==> Caveats
libomp is keg-only, which means it was not symlinked into /usr/local,
because it can override GCC headers and result in broken builds.
==> Analytics
install: 59,153 (30 days), 190,820 (90 days), 659,209 (365 days)
install-on-request: 16,568 (30 days), 48,711 (90 days), 149,139 (365 days)
build-error: 5 (30 days)
@lainy @d235j any ideas on what's going on here? This is a v0.1 release blocker and I can't reproduce on my mac mini
I see there is a difference between /usr/local/cellar here and the script I put earlier which is looking in /opt/homebrew. I wonder if it is related to rosetta vs native aarch brew package installation?
Very possible. Are you using a rosetta setup? ngscopeclient should build and run fine under native aarch64.
I am not intentionally using rosetta (arch returns arm64`) but I am wondering if the keg or whatever brew calls the package is hosted primary as x86 or something.
~~I actually just checked and I don't seem to have libomp in /opt/homebrew, somehow. So I'm not sure how my earlier fix in OP helped me.~~ I was only looking in /opt/homebrew/lib but should have looked in /opt/homebrew/opt, I do have it installed there.
It sounds like you have remnants of x86_64 Homebrew in /usr/local, and the libomp and other Homebrew dependencies you have are x86_64, not arm64. arm64 Homebrew installs in /opt/homebrew not /usr/local.
I recommend clearing this out, which likely means running the Homebrew uninstaller script in Rosetta and then manually cleaning out what's left there.
I do not recommend x86_64 Homebrew. If you need libraries for use under x86_64 or Rosetta, it's best to install in a separate prefix that isn't /usr/local.
Removed brew (both native and x86_64) using scripts here: https://github.com/homebrew/install?tab=readme-ov-file#uninstall-homebrew
However, I still get the issue! Even with logout/login and making sure to add env vars for libomp installations...
$: brew info libomp
==> libomp: stable 20.1.7 (bottled) [keg-only]
LLVM's OpenMP runtime library
https://openmp.llvm.org/
Installed
/opt/homebrew/Cellar/libomp/20.1.7 (9 files, 1.7MB)
Poured from bottle using the formulae.brew.sh API on 2025-06-24 at 22:29:01
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/lib/libomp.rb
License: MIT
==> Dependencies
Build: cmake ✔, lit ✘
==> Caveats
libomp is keg-only, which means it was not symlinked into /opt/homebrew,
because it can override GCC headers and result in broken builds.
For compilers to find libomp you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"
==> Analytics
install: 59,509 (30 days), 190,000 (90 days), 656,684 (365 days)
install-on-request: 16,637 (30 days), 48,719 (90 days), 148,764 (365 days)
build-error: 5 (30 days)
@d235j
$: brew info libomp
==> libomp: stable 20.1.7 (bottled) [keg-only]
LLVM's OpenMP runtime library
https://openmp.llvm.org/
Installed
/opt/homebrew/Cellar/libomp/20.1.7 (9 files, 1.7MB)
Poured from bottle using the formulae.brew.sh API on 2025-06-24 at 22:29:01
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/lib/libomp.rb
License: MIT
==> Dependencies
Build: cmake ✔, lit ✘
==> Caveats
libomp is keg-only, which means it was not symlinked into /opt/homebrew,
because it can override GCC headers and result in broken builds.
For compilers to find libomp you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"
==> Analytics
install: 55,414 (30 days), 187,645 (90 days), 653,338 (365 days)
install-on-request: 15,926 (30 days), 48,685 (90 days), 148,722 (365 days)
build-error: 5 (30 days)
Trying to build:
$: cmake ..
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) (found version "5.1")
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) (found version "5.1")
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
CMake Error at CMakeLists.txt:155 (message):
ngscopeclient requires OpenMP but your C++ compiler does not appear to
support it.
-- Configuring incomplete, errors occurred!
Manually removed what was in /usr/local/lib (and /usr/local/bin) for libOMP :
$: ls /usr/local/lib | grep omp
libOGLCompiler.a
libdxcompiler.3.7.dylib
libdxcompiler.dylib
You need to pass some parameters to cmake as is covered in section 3.3.2 of the manual at https://www.ngscopeclient.org/downloads/ngscopeclient-manual.pdf#page24 . Otherwise it won't be able to find OpenMP.
Doesn't matter, I get the same output:
$: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(brew --prefix);$(brew --\
prefix)/opt/libomp"
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) (found version "5.1")
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) (found version "5.1")
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
CMake Error at CMakeLists.txt:155 (message):
ngscopeclient requires OpenMP but your C++ compiler does not appear to
support it.
-- Configuring incomplete, errors occurred!
Oh, that path doesn't seem right, let me check that.
I tried pointing it here: /opt/homebrew/Cellar/libomp/20.1.7 as shown by brew as install location but that doesn't work either (I don't know a lot about brew). I do have libraries in /opt/homebrew/opt/libomp.
/opt/homebrew/Cellar/libomp/20.1.7 and /opt/homebrew/opt/libomp should both point to the same place. I’ll debug once I’m back at a Mac…
@d235j any luck?