A
aftnix
I've give `-lrt` as the last linker flag to the compiler. But still
getting this error.
arif@khost:~/sak/sak.exosip$ gcc eXo_init.c -I/opt/osip2/include
-I/opt/exosip/include -L/opt/osip2/lib -L/opt/exosip/lib -leXosip2
-losipparser2 -losip2 -lrt
/opt/osip2/lib/libosip2.so: undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
The man page says :
NAME
clock_getres, clock_gettime, clock_settime - clock and time functions
SYNOPSIS
#include <time.h>
int clock_getres(clockid_t clk_id, struct timespec *res);
int clock_gettime(clockid_t clk_id, struct timespec *tp);
int clock_settime(clockid_t clk_id, const struct timespec *tp);
Link with -lrt.
So i'm kind of confused where i'm doing it wrong.
I've tried to read symbols in `librt.so` with no luck :
arif@khost:~/sak/ortp/src/tests$ nm /lib/x86_64-linux-gnu/librt-2.15.so
nm: /lib/x86_64-linux-gnu/librt-2.15.so: no symbols
The reason i can't read symbols out of `librt.so` is that they are "stripped".
arif@khost:~/sak/ortp/src/tests$ file /lib/x86_64-linux-gnu/librt-2.15.so
/lib/x86_64-linux-gnu/librt-2.15.so: ELF 64-bit LSB shared object,
x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
BuildID[sha1]=0x375b2c35c4e6503a5d1a88ab6f76f5b6e0ee81df, for
GNU/Linux 2.6.24, stripped
Well things become very confusing because the following test code
compiles and runs just fine :
#include <time.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv, char **arge) {
struct timespec tps, tpe;
if ((clock_gettime(CLOCK_REALTIME, &tps) != 0)
|| (clock_gettime(CLOCK_REALTIME, &tpe) != 0)) {
perror("clock_gettime");
return -1;
}
printf("%lu s, %lu ns\n", tpe.tv_sec-tps.tv_sec,tpe.tv_nsec-tps.tv_nsec);
return 0;
}
Built with
arif@khost:~/sak/sak.exosip$ gcc what.c -lrt
The code i'm trying to compile is :
#include <eXosip2/eXosip.h>
#include <netinet/in.h>
#include <unistd.h>
int ex_init(int port)
{
struct eXosip_t *eXcontext;
int i;
TRACE_INITIALIZE(6, stdout);
i = eXosip_init(eXcontext);
if (i != 0)
return -1;
i = eXosip_listen_addr(eXcontext, IPPROTO_UDP, NULL, port, AF_INET, 0);
if (i != 0) {
eXosip_quit(eXcontext);
fprintf (stderr, "could not initialize transport layer\n");
return -1;
}
return 1;
}
int main(int argc, char **argv) {
if(ex_init(1000))
printf("success \n");
return 0;
}
getting this error.
arif@khost:~/sak/sak.exosip$ gcc eXo_init.c -I/opt/osip2/include
-I/opt/exosip/include -L/opt/osip2/lib -L/opt/exosip/lib -leXosip2
-losipparser2 -losip2 -lrt
/opt/osip2/lib/libosip2.so: undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
The man page says :
NAME
clock_getres, clock_gettime, clock_settime - clock and time functions
SYNOPSIS
#include <time.h>
int clock_getres(clockid_t clk_id, struct timespec *res);
int clock_gettime(clockid_t clk_id, struct timespec *tp);
int clock_settime(clockid_t clk_id, const struct timespec *tp);
Link with -lrt.
So i'm kind of confused where i'm doing it wrong.
I've tried to read symbols in `librt.so` with no luck :
arif@khost:~/sak/ortp/src/tests$ nm /lib/x86_64-linux-gnu/librt-2.15.so
nm: /lib/x86_64-linux-gnu/librt-2.15.so: no symbols
The reason i can't read symbols out of `librt.so` is that they are "stripped".
arif@khost:~/sak/ortp/src/tests$ file /lib/x86_64-linux-gnu/librt-2.15.so
/lib/x86_64-linux-gnu/librt-2.15.so: ELF 64-bit LSB shared object,
x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
BuildID[sha1]=0x375b2c35c4e6503a5d1a88ab6f76f5b6e0ee81df, for
GNU/Linux 2.6.24, stripped
Well things become very confusing because the following test code
compiles and runs just fine :
#include <time.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char **argv, char **arge) {
struct timespec tps, tpe;
if ((clock_gettime(CLOCK_REALTIME, &tps) != 0)
|| (clock_gettime(CLOCK_REALTIME, &tpe) != 0)) {
perror("clock_gettime");
return -1;
}
printf("%lu s, %lu ns\n", tpe.tv_sec-tps.tv_sec,tpe.tv_nsec-tps.tv_nsec);
return 0;
}
Built with
arif@khost:~/sak/sak.exosip$ gcc what.c -lrt
The code i'm trying to compile is :
#include <eXosip2/eXosip.h>
#include <netinet/in.h>
#include <unistd.h>
int ex_init(int port)
{
struct eXosip_t *eXcontext;
int i;
TRACE_INITIALIZE(6, stdout);
i = eXosip_init(eXcontext);
if (i != 0)
return -1;
i = eXosip_listen_addr(eXcontext, IPPROTO_UDP, NULL, port, AF_INET, 0);
if (i != 0) {
eXosip_quit(eXcontext);
fprintf (stderr, "could not initialize transport layer\n");
return -1;
}
return 1;
}
int main(int argc, char **argv) {
if(ex_init(1000))
printf("success \n");
return 0;
}