[lttng-dev] linking c++ with shared object tracepoints
Aryeh Weinreb
weinrea at gmail.com
Tue Jun 4 11:37:50 EDT 2013
> I prepared a quick and dirty example based on the "demo" project.
> Replace the Makefile and demo.c files with these:
> https://gist.github.com/jgalar/5706595
>
> This will compile a C++ application which links against the
> lttng-ust-provider-ust-tests-demo3.so provider.
>
> Resulting trace:
> [10:59:42.399354875] (+?.?????????) mercury:demo:16256
> ust_tests_demo3:done: { cpu_id = 4 }, { value = 42 }
>
> Regards,
> Jérémie
Thanks.
Unfortunately, this is not working for me.
Making all in demo
make[3]: Entering directory `/home/nkw643/lttng-ust-2.1.2/tests/demo'
g++ -c -o demo.o demo.cpp
gcc -I. -fpic -c -o tp3.o tp3.c
gcc -shared -o lttng-ust-provider-ust-tests-demo3.so -llttng-ust tp3.o
g++ -o demo demo.o lttng-ust-provider-ust-tests-demo3.so -L. -ldl
-Wl,-rpath=.
/usr/bin/ld: demo: hidden symbol `tracepoint_dlopen' in demo.o is
referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
$ nm -s demo.o | grep tracepoint_dlopen
0000000000000020 V tracepoint_dlopen
$ nm -s .libs/liblttng-ust-provider-ust-tests-demo3.so | grep
tracepoint_dlopen
U tracepoint_dlopen
$ readelf -s demo.o | grep tracepoint_dlopen
34: 0000000000000020 48 OBJECT WEAK HIDDEN 6 tracepoint_dlopen
$ readelf -s .libs/liblttng-ust-provider-ust-tests-demo3.so | grep
tracepoint_dlopen
6: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND tracepoint_dlopen
67: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND tracepoint_dlopen
$readelf -d demo.o | grep tracepoint_dlopen
$
$readelf -d .libs/liblttng-ust-provider-ust-tests-demo3.so | grep
tracepoint_dlopen
$
More information about the lttng-dev
mailing list