This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch hotfix/492-unresolved-symbols-check in repository https://gitbox.apache.org/repos/asf/celix.git
commit 61c814a38b8f9e147b27bb75837572f2d7e27a8b Author: PengZheng <[email protected]> AuthorDate: Mon Apr 28 12:59:07 2025 +0800 Check for unresolved symbols at build-time rather than runtime. --- bundles/remote_services/examples/calculator_service/CMakeLists.txt | 2 +- .../remote_services/examples/remote_example_service/CMakeLists.txt | 2 +- cmake/cmake_celix/BundlePackaging.cmake | 5 +++++ libs/framework/src/celix_libloader.c | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bundles/remote_services/examples/calculator_service/CMakeLists.txt b/bundles/remote_services/examples/calculator_service/CMakeLists.txt index 0c010a5b0..bc7fcfb44 100644 --- a/bundles/remote_services/examples/calculator_service/CMakeLists.txt +++ b/bundles/remote_services/examples/calculator_service/CMakeLists.txt @@ -23,7 +23,7 @@ add_celix_bundle(calculator VERSION 0.0.1 ) target_include_directories(calculator PRIVATE src) -target_link_libraries(calculator PRIVATE Celix::c_rsa_spi calculator_api) +target_link_libraries(calculator PRIVATE Celix::c_rsa_spi calculator_api m) get_target_property(DESCR calculator_api INTERFACE_DESCRIPTOR) celix_bundle_files(calculator ${DESCR} DESTINATION .) diff --git a/bundles/remote_services/examples/remote_example_service/CMakeLists.txt b/bundles/remote_services/examples/remote_example_service/CMakeLists.txt index fa94c150b..61e2d5403 100644 --- a/bundles/remote_services/examples/remote_example_service/CMakeLists.txt +++ b/bundles/remote_services/examples/remote_example_service/CMakeLists.txt @@ -23,7 +23,7 @@ add_celix_bundle(remote_example_service VERSION 0.0.1 ) target_include_directories(remote_example_service PRIVATE src) -target_link_libraries(remote_example_service PRIVATE Celix::c_rsa_spi remote_example_api) +target_link_libraries(remote_example_service PRIVATE Celix::c_rsa_spi remote_example_api m) get_target_property(DESCR remote_example_api INTERFACE_DESCRIPTOR) celix_bundle_files(remote_example_service ${DESCR} DESTINATION .) diff --git a/cmake/cmake_celix/BundlePackaging.cmake b/cmake/cmake_celix/BundlePackaging.cmake index 4be1c48f7..9c1335e87 100644 --- a/cmake/cmake_celix/BundlePackaging.cmake +++ b/cmake/cmake_celix/BundlePackaging.cmake @@ -251,6 +251,11 @@ function(add_celix_bundle) "BUNDLE_TARGET" "${BUNDLE_TARGET_NAME}_bundle" ) target_link_libraries(${BUNDLE_TARGET_NAME} PRIVATE Celix::framework) + if(APPLE) + target_link_options(${BUNDLE_TARGET_NAME} PRIVATE "-Wl,-undefined,error") + else () + target_link_options(${BUNDLE_TARGET_NAME} PRIVATE "-Wl,-z,defs") + endif() else () add_custom_target(${BUNDLE_TARGET_NAME}) set_target_properties(${BUNDLE_TARGET_NAME} PROPERTIES diff --git a/libs/framework/src/celix_libloader.c b/libs/framework/src/celix_libloader.c index f11053bff..ea2bdbf62 100644 --- a/libs/framework/src/celix_libloader.c +++ b/libs/framework/src/celix_libloader.c @@ -29,9 +29,9 @@ celix_library_handle_t* celix_libloader_open(celix_bundle_context_t *ctx, const #endif celix_library_handle_t* handle = NULL; bool noDelete = celix_bundleContext_getPropertyAsBool(ctx, CELIX_LOAD_BUNDLES_WITH_NODELETE, defaultNoDelete); - int flags = RTLD_NOW|RTLD_LOCAL; + int flags = RTLD_LAZY|RTLD_LOCAL; if (noDelete) { - flags = RTLD_NOW|RTLD_LOCAL|RTLD_NODELETE; + flags = RTLD_LAZY|RTLD_LOCAL|RTLD_NODELETE; } handle = dlopen(libPath, flags);
