【发布时间】:2020-02-29 05:02:39
【问题描述】:
我有一个使用 Jaeger 进行跟踪的 c++ 程序
#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;
}
}
我使用它编译它
g++ -std=c++1z test.cpp -I /usr/local/lib/ -ljaegertracing -lyaml-cpp哪里
/usr/local/lib/libyaml-cpp.a是安装路径。
错误信息 -
/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
我已经通过下载源代码安装了yaml-cpp-0.6.0 .tar 版本没有mkdir build,cd build,sudo make,sudo make install
我不知道为什么我的编译失败了。
我在yaml-cpp/build 目录中有libyaml-cppd.so.0.6 并尝试使用此路径进行编译,但仍然失败。
操作系统 - ubuntu 18.04
【问题讨论】:
-
我还没有尝试过。我会尽快尝试更新你。 :)