dynamic_library_lin.cpp
Go to the documentation of this file.
1 
11 #include "dynamic_library.h"
12 
14 
15 #include <dlfcn.h>
16 
17 namespace
18 {
19 
20 void * LoadLibrary(const char * path)
21 {
22  void * library = dlopen(path, RTLD_LAZY);
23 
24  if (!library)
25  {
26  std::string msg;
27 
28  if (const char * err = dlerror())
29  {
30  msg = err;
31  }
32 
34  }
35 
36  return library;
37 }
38 
39 }
40 
41 namespace Common
42 {
43 
45  : Path(libraryPath)
46  , Library(0)
47 {
48 }
49 
51 {
52  if (Library)
53  {
54  //dlclose(Library);
55  }
56 }
57 
58 void * DynamicLibrary::FindSymbol(const std::string & funcName)
59 {
60  if (!Library)
61  {
62  Library = LoadLibrary(Path.c_str());
63  }
64 
65  void * func = dlsym(Library, funcName.c_str());
66 
67  if (!func)
68  {
69  std::string msg;
70 
71  if (const char * err = dlerror())
72  {
73  msg = err;
74  }
75 
77  }
78 
79  return func;
80 }
81 
82 }
Addon interface definition GNU LGPL.
const std::string Path
void * FindSymbol(const std::string &funcName)
Common::ErrorData UnableToLoadDynamicLibrary
DynamicLibrary(const std::string &libraryPath)
#define THROW_ERROR2(data, param1, param2)
Definition: exception.h:215
Common::ErrorData UnableToFundSymbolInTheLibrary
#define THROW_ERROR3(data, param1, param2, param3)
Definition: exception.h:218


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:06:04