Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/celix-examples/hello_world_cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ add_celix_bundle(hello_world_cxx
SOURCES src/BundleActivator.cc
)

set_target_properties(hello_world_cxx PROPERTIES LINK_FLAGS -Wl,--no-as-needed)
target_link_libraries(hello_world_cxx PRIVATE -ldl)

add_celix_container(hello_world_cxx_container
BUNDLES
Celix::shell
Celix::shell_tui
hello_world_cxx
Jansson
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ namespace /*anon*/ {

class BundleActivator {
public:
BundleActivator(std::shared_ptr<celix::dm::DependencyManager> _mng) : mng{_mng} {
explicit BundleActivator(std::shared_ptr<celix::dm::DependencyManager> _mng) : mng{std::move(_mng)} {
std::cout << "Hello world from C++ bundle with id " << bndId() << std::endl;
auto bnd = celix_bundleContext_getBundle(mng->bundleContext());
auto dlsym = celix_bundle_dlsym(bnd, "json_true");
std::cout << "dlsym: " << (dlsym == nullptr ? "nullptr" : "found") << "\n";

}
~BundleActivator() {
std::cout << "Goodbye world from C++ bundle with id " << bndId() << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion libs/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ if (ENABLE_TESTING AND FRAMEWORK_TESTS)
src/bundle.c
src/celix_errorcodes.c
private/mock/celix_log_mock.c)
target_link_libraries(bundle_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread)
target_link_libraries(bundle_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} Celix::utils pthread -ldl)

add_executable(capability_test
private/test/capability_test.cpp
Expand Down
2 changes: 2 additions & 0 deletions libs/framework/include/celix_bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ celix_array_list_t* celix_bundle_listServiceTrackers(const celix_bundle_t *bnd);
*/
void celix_bundle_destroyServiceTrackerList(celix_array_list_t* list);

void* celix_bundle_dlsym(const celix_bundle_t *bnd, const char * symbol);


#ifdef __cplusplus
}
Expand Down
5 changes: 5 additions & 0 deletions libs/framework/src/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <service_tracker.h>
#include <celix_constants.h>
#include <celix_api.h>
#include <dlfcn.h>

#include "framework_private.h"
#include "bundle_private.h"
Expand Down Expand Up @@ -704,4 +705,8 @@ void celix_bundle_destroyServiceTrackerList(celix_array_list_t* list) {
}
celix_arrayList_destroy(list);
}
}

void* celix_bundle_dlsym(const celix_bundle_t *bnd, const char * symbol) {
return dlsym(bnd->handle, symbol);
}