-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnative_lib.cpp
More file actions
52 lines (40 loc) · 796 Bytes
/
native_lib.cpp
File metadata and controls
52 lines (40 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "native_lib.h"
#ifdef _WIN32
HLIB openLibrary(const char *lib_name)
{
return LoadLibrary(lib_name);
}
HFUNC getFunctionAddr(HLIB lhandle, const char *func_name)
{
return GetProcAddress(lhandle, func_name);
}
void closeLibrary(HLIB lhandle)
{
FreeLibrary(lhandle);
}
string getLibFullName(string lib_name)
{
return lib_name + ".dll";
}
#elif __linux__
HLIB openLibrary(const char *lib_name)
{
return dlopen(lib_name, RTLD_LAZY);
}
HFUNC getFunctionAddr(HLIB lhandle, const char *func_name)
{
return dlsym(lhandle, func_name);
}
void closeLibrary(HLIB lhandle)
{
dlclose(lhandle);
}
string getLibFullName(string lib_name)
{
if (lib_name.compare("libc") == 0)
lib_name += ".so.6";
else
lib_name += ".so";
return lib_name;
}
#endif