Reputation: 308
I downloaded custom glibc and then compiled using g++ dt.cpp -std=c++11 -Wl,-rpath "/opt/glibc-2.28/lib"
, but it gives seg fault
#include <iostream>
#include <ctime>
int main()
{
std::tm tm = {};
char* result = strptime ("2024-11-07", "%Y-%m-%d", &tm);
if(result)
printf("Result: *%d*\n", tm.tm_mday);
time_t time_ = std::mktime (&tm);
std::cout << "mytime: " << time_ << std::endl;
}
ldd for the binary gives the following
linux-vdso.so.1 (0x00007ffc073f9000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f85cda5e000)
libc.so.6 => /opt/glibc-2.28/lib/libc.so.6 (0x00007f85cd6a7000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f85cd309000)
/lib64/ld-linux-x86-64.so.2 (0x00007f85ce0c1000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f85cd0e6000)
Upvotes: 0
Views: 33
Reputation: 213869
but it gives seg fault
That is expected, because you are mixing the dynamic loader /lib64/ld-linux-x86-64.so.2
with an incompatible /opt/glibc-2.28/lib/libc.so.6
.
See also this answer for a solution.
Upvotes: 1