diff --git a/CMakeLists.txt b/CMakeLists.txt index f117f9d1d..a893e0854 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -771,7 +771,11 @@ if (NOT MNN_BUILD_SHARED_LIBS) if(CMAKE_SYSTEM_NAME MATCHES "^Linux") set(MNN_DEPS -Wl,--whole-archive ${MNN_DEPS} -lpthread -Wl,--no-whole-archive) else() + if(APPLE) + set(MNN_DEPS -Wl,-force_load ${MNN_DEPS}) + else() set(MNN_DEPS -Wl,--whole-archive ${MNN_DEPS} -Wl,--no-whole-archive) + endif() endif() endif() endif() diff --git a/tools/converter/CMakeLists.txt b/tools/converter/CMakeLists.txt index af11eed51..07a3da727 100644 --- a/tools/converter/CMakeLists.txt +++ b/tools/converter/CMakeLists.txt @@ -51,7 +51,7 @@ IF(MNN_BUILD_CONVERTER) target_link_libraries(MNNConvertDeps PUBLIC ${TORCH_LIBRARIES}) endif() if(APPLE) - target_link_libraries(MNNConvert -Wl,-all_load MNNConvertDeps ${MNN_DEPS} -Wl,-noall_load) + target_link_libraries(MNNConvert -Wl,-all_load MNNConvertDeps ${MNN_DEPS}) elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") # See also /path/to/MNN/CMakeLists.txt:481 when you are confused with -lpthread here. target_link_libraries(MNNConvert -Wl,--whole-archive MNNConvertDeps ${MNN_DEPS} -lpthread -Wl,--no-whole-archive)