You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS High Sierra下CMake链接Bonmin报错:ld: framework not found -lAccelerate

Troubleshooting Bonmin Linking Issues with CMake on macOS High Sierra (10.13.4) + Xcode 9.3

Hey there, let’s work through this Bonmin linking problem together. Since the native Makefile for the Bonmin example compiles fine, the issue almost certainly stems from how CMake is locating or binding Bonmin’s libraries and its COIN-OR dependencies. Here are targeted fixes to get your project running:

1. Validate Your Bonmin Build Configuration

First, double-check the flags you used when compiling Bonmin — mismatched build settings are a common culprit:

  • When you ran ../configure -C --d..., make sure you added a C++ standard flag that matches your CMake project (Xcode 9.3 defaults to C++14). For example:
    ../configure -C --enable-shared --with-cxxflags="-std=c++14"
    
  • Confirm you built Bonmin as a shared library with --enable-shared — static libraries can cause linking headaches on macOS, especially with COIN-OR’s nested dependencies.

2. Explicitly Tell CMake Where to Find Bonmin

CMake needs clear paths to Bonmin’s headers and libraries. Add these lines to your CMakeLists.txt:

# Replace with your actual Bonmin installation path
set(BONMIN_INSTALL_DIR "/PATH_TO_BONMIN/Bonmin")

# Include Bonmin header directories
include_directories(
    ${BONMIN_INSTALL_DIR}/include
    ${BONMIN_INSTALL_DIR}/../CoinUtils/include
    ${BONMIN_INSTALL_DIR}/../Osi/include
    ${BONMIN_INSTALL_DIR}/../Cbc/include
)

# Locate and link Bonmin + its dependencies
find_library(BONMIN_LIB bonmin PATHS ${BONMIN_INSTALL_DIR}/lib)
find_library(COINUTILS_LIB CoinUtils PATHS ${BONMIN_INSTALL_DIR}/../CoinUtils/lib)
find_library(OSI_LIB Osi PATHS ${BONMIN_INSTALL_DIR}/../Osi/lib)
find_library(CBC_LIB Cbc PATHS ${BONMIN_INSTALL_DIR}/../Cbc/lib)

target_link_libraries(YourProjectTargetName
    ${BONMIN_LIB}
    ${COINUTILS_LIB}
    ${OSI_LIB}
    ${CBC_LIB}
    # Add other COIN-OR libraries as needed (e.g., Cgl)
)

Don’t forget to replace /PATH_TO_BONMIN with your actual installation path and YourProjectTargetName with your CMake target’s name.

3. Fix Xcode-Specific Linking Quirks

macOS and Xcode have unique behavior when it comes to library loading:

  • Add set(CMAKE_MACOSX_RPATH ON) to your CMakeLists.txt — this ensures the runtime can find Bonmin’s libraries when you run your executable, avoiding "library not found" errors.
  • If you’re using static Bonmin libraries, add this flag to force linking all symbols (COIN-OR static libs often require this on macOS):
    set(CMAKE_EXE_LINKER_FLAGS "-Wl,-all_load")
    

4. Compare Working Makefile vs. CMake Build Logs

Since the Bonmin example’s Makefile works, use it as a reference:

  • Run make VERBOSE=1 in the /PATH_TO_BONMIN/Bonmin/examples/CppExample directory to see the exact compiler/linker flags the working build uses.
  • In your CMake project, run cmake --build . --verbose to get its build commands. Look for differences in:
    • Include paths (-I flags)
    • Library paths (-L flags)
    • Linked libraries (-l flags)
    • C++ standard flags (-std=...)
      Copy any missing flags from the working Makefile into your CMakeLists.txt using add_compile_options() or target_compile_options().

5. Ensure Toolchain Consistency

Xcode 9.3 uses Apple LLVM 9.1.0 — make sure Bonmin was compiled with the same compiler:

  • Re-run configure with explicit compiler paths to match Xcode’s clang:
    ../configure -C --enable-shared --with-cxxflags="-std=c++14" CC=/usr/bin/clang CXX=/usr/bin/clang++
    

This avoids ABI mismatches between Bonmin and your CMake project.

If you still hit errors, share the exact linking output from CMake — that’ll help narrow down the issue even more!

内容的提问来源于stack exchange,提问作者Franzi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:36:12