[lttng-dev] Unable to use libbabeltrace for trace reading in C program
Julien Desfossez
jdesfossez at efficios.com
Tue Feb 23 19:13:05 EST 2016
Hi,
> Hi,
>
> I’m trying to use the babeltrace library to be able to load and read a CTF trace in a C program.
>
> From the doc:
>
> > In order to use libbabeltrace to read a trace, the first step is to create a
> > context structure and to add a trace to it. This is done using the
> > bt_context_create() and bt_context_add_trace() functions. As long as this
> > context structure is allocated and the trace is valid, the trace can be
> > manipulated by the library.
>
>
> But for a simple program like this:
>
> > #include <stdio.h>
> > #include <babeltrace/context.h>
> >
> > int main(void){
> >
> > struct bt_context *ctx = bt_context_create();
> >
> > int ret = bt_context_add_trace(ctx, "/home/alex/trace/ffmpeg/kernel/", "ctf", NULL, NULL, NULL);
> >
> > return ret;
> >
> > }
>
>
> I got the following error message:
>
> > [error] [Context] Format "ctf" unknown.
It sounds like a linking problem, try to compile with this, it should
work:
gcc -o a a.c -lbabeltrace -Wl,--no-as-needed -lbabeltrace-ctf
I don't know if there is a cleaner solution, others will know.
Babeltrace discovers its supported formats with the libraries loaded
when the program starts.
Julien
More information about the lttng-dev
mailing list