Skip to content

Commit

Permalink
Shared library working on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández <ahcorde@gmail.com>
  • Loading branch information
ahcorde committed Mar 10, 2020
1 parent 0e69e81 commit 5bcd3b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 7 additions & 1 deletion include/rcutils/shared_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ extern "C"

#include <string.h>

#ifndef _WIN32
#include <dlfcn.h>
#else
#include <windows.h>
#endif // _WIN32

#include "rcutils/macros.h"
#include "rcutils/visibility_control.h"

Expand All @@ -32,7 +38,7 @@ typedef struct rcutils_shared_library_t
#ifndef _WIN32
void * lib_pointer;
#else
HINSTANCE lib;
HINSTANCE lib_pointer;
#endif
/// The path of the shared_library
char * library_path;
Expand Down
7 changes: 1 addition & 6 deletions src/shared_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ extern "C"

#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
#include <dlfcn.h>
#else
#include <windows.h>
#endif // _WIN32

rcutils_shared_library_t *
rcutils_get_shared_library(const char * library_path)
Expand All @@ -35,7 +30,7 @@ rcutils_get_shared_library(const char * library_path)
#ifndef _WIN32
lib->lib_pointer = dlopen(library_path, RTLD_LAZY);
#else
lib->lib_pointer = LoadLibrary(library_path.c_str());
lib->lib_pointer = LoadLibrary(library_path);
#endif // _WIN32
if (!lib->lib_pointer) {
free(lib);
Expand Down

0 comments on commit 5bcd3b4

Please sign in to comment.