I have a c++ program which using Jaeger for tracing
#include <iostream>
#include<memory>
#include <yaml-cpp/yaml.h>
// #include <opentracing/tracer.h>
#include<jaegertracing/Tracer.h>
namespace std
{
void init(const char *FilePath)
{
auto yaml = YAML::LoadFile(FilePath);
auto config = jaegertracing::Config::parse(yaml);
auto tracer=jaegertracing::Tracer::make(
"example-service",
config,
jaegertracing::logging::consoleLogger()
);
opentracing::Tracer::InitGlobal(
static_pointer_cast<opentracing::Tracer>(tracer)
);
}
void ChildSpan(const unique_ptr<opentracing::Span>& parentSpan){
this_thread::sleep_for(1ms);
auto childSpan = opentracing::Tracer::Global()->StartSpan("Span2",{opentracing::ChildOf(&parentSpan->context())});
}
void FollowsSpan(const unique_ptr<opentracing::Span>& followFromspan){
this_thread::sleep_for(2ms);
auto followSpan = opentracing::Tracer::Global()->StartSpan("Span3",{opentracing::FollowsFrom(&followFromspan->context())});
}
void ParentSpan(){
auto span = opentracing::Tracer::Global()->StartSpan("Span1");
ChildSpan(span);
FollowsSpan(span);
this_thread::sleep_for(3ms);
}
int main()
{
init("./config.yaml");
ParentSpan();
return 0;
}
}
I compile it using
g++ -std=c++1z test.cpp -I /usr/local/lib/ -ljaegertracing -lyaml-cpp
where
/usr/local/lib/libyaml-cpp.a
is the installation path.
Error message -
/usr/bin/ld: warning: libyaml-cppd.so.0.6, needed by //usr/local/lib/libjaegertracing.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
I have installed yaml-cpp-0.6.0
by downloading source code .tar
version did mkdir build
,cd build
,sudo make
,sudo make install
I dont know why my compilation is failing.
I have libyaml-cppd.so.0.6
in yaml-cpp/build
directory and tried this path to compile but still it is failing.
OS - ubuntu 18.04