Skip to content
Open
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
7 changes: 7 additions & 0 deletions test/multi_agent_dlopen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
INCLUDE(CheckIncludeFile)

check_include_file(gnu/lib-names.h HAVE_GNU_LIBNAMES_H)

set(CMAKE_C_FLAGS "-g -O -fPIC")
add_library(multi_agent_sym SHARED dlsym.c)
add_library(multi_agent_mon SHARED monitor.c)
add_executable(multi_agent_main main.c)
if(HAVE_GNU_LIBNAMES_H)
target_compile_definitions(multi_agent_main PRIVATE -DHAVE_GNU_LIBNAMES_H)
endif()
target_link_libraries(multi_agent_main dl)
target_link_libraries(multi_agent_mon dl gotcha)
gotcha_add_test(multi_agent_dlopen multi_agent_main)
Expand Down
10 changes: 9 additions & 1 deletion test/multi_agent_dlopen/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
#include <math.h>
#include <stdio.h>

#ifdef HAVE_GNU_LIBNAMES_H
#include <gnu/lib-names.h>
#endif

#ifndef LIBM_SO
#define LIBM_SO "libm.so"
#endif

#define MYNAME "main"

typedef double sin_fcn_t(double);
Expand All @@ -21,7 +29,7 @@ main(int argc, char **argv)

fprintf(stderr, "%s: val = %.6f\n", MYNAME, val);

void *handle = dlopen("libm.so", RTLD_NOW);
void *handle = dlopen(LIBM_SO, RTLD_NOW);
if (handle == NULL) {
err(1, "dlopen failed");
}
Expand Down