forked from nothingelsematters/libs-acquaintance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (23 loc) · 680 Bytes
/
main.cpp
File metadata and controls
30 lines (23 loc) · 680 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
#include <iostream>
#include <dlfcn.h>
#include "libs/static/get_day.h"
#include "libs/dynamic1/get_month.h"
//int get_day();
//int get_month();
int main() {
void* handle = dlopen("libget_year.so", RTLD_LAZY);
if (handle == nullptr) {
std::cerr << dlerror() << std::endl;
exit(EXIT_FAILURE);
}
int (*get_year)() = reinterpret_cast<int (*)()>(dlsym(handle, "get_year"));
if (get_year == nullptr) {
std::cerr << dlerror() << std::endl;
exit(EXIT_FAILURE);
}
printf("Today is %d/%d/%d", get_day(), get_month(), get_year());
if (dlclose(handle) != 0) {
std::cerr << dlerror() << std::endl;
}
return 0;
}