I am trying to instrument my program with jaeger-tracing (c++).
I was able to view my traces when I compliled the program with yaml-cpp version 0.5.3, but when I changed my yaml-cpp version to 0.6.x, I am unable to view my traces.
Dont know why its happening.
JaegerProgram Source code;
#include <iostream>
#include<memory>
#include <yaml-cpp/yaml.h>
#include<jaegertracing/Tracer.h>
#include<chrono>
using namespace std;
// using namespace literals::chrono_literals;
void init(const char *FilePath)
{
auto yaml = YAML::LoadFile(FilePath);
auto config = jaegertracing::Config::parse(yaml);
auto tracer=jaegertracing::Tracer::make(
"example-service-2",
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(chrono::milliseconds(2));
auto childSpan = opentracing::Tracer::Global()->StartSpan("Span2",{opentracing::ChildOf(&parentSpan->context())});
}
void FollowsSpan(const unique_ptr<opentracing::Span>& followFromspan){
this_thread::sleep_for(chrono::milliseconds(3));
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(chrono::milliseconds(4));
}
int main()
{
init("./config.yaml");
ParentSpan();
cout<<"Hello World"<<endl;
opentracing::Tracer::Global()->Close();
return 0;
}
compiling command - g++ -std=c++1z test.cpp -L /usr/local/lib/libyaml-cpp.a -ljaegertracing -lyaml-cpp
Yaml file
disabled: false
reporter:
logSpans: true
sampler:
type: const
param: 1
OS : ubuntu 18.04
jaegerTracing : master branch version
UPDATE
after little digging I found some fact, When I parse the above mention config file try to print the result I get the same value as written in config file, but when I parse same file using yaml-cpp-0.6.x the sampler.type is showing 'remote' and sampler.param to be '0.001' and when I manually change this change these values to be same as in config.yaml it has started showing traces. The error is present in parsing the yaml file as I could clearly see different values is loaded as configuration.
Related
Is it possible for codelets to reference code in other files, like header files?
If I have a codelet file
//FileA.cpp
#include "FileB.h"
class SomeCustomVertex : public Vertex {
public:
bool compute() {
int a = SomeConstantDefinedInFileB;
}
...
}
and some other "codelet" file
//FileB.h
const int SomeConstantDefineInFileB = 42;
and in the host graph program:
graph.addCodelets({"codelets/FileA.cpp", "codelets/FileB.h"});
I get a compile error from popc:
fatal error: 'FileB.h' file not found
#include "FileB.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
terminate called after throwing an instance of 'poplar::graph_program_compilation_error'
what(): Codelet compilation failed (see compiler output for details)
I figured this out.
Graph::addCodelets has a parameter StringRef compileFlags = "", which you can use to inject compiler options.
popc --help shows an option
-I arg Add directory to include search path
So when I use graph.addCodelets({"codelets/FileA.cpp"}, "-I codelets"); in the host program, and have my codelets in 'codelets' subdirectory, this works. No need to explicitly list the ".h" files in the arguments.
Incidentally, also a good way to ensure compiler optimisation (-O3) for the custom codelets.
I’m making a standalone ROOT application which should terminate upon closing a canvas. The following is my experimental code.
#include "TROOT.h"
#include "TApplication.h"
#include "TCanvas.h"
int main(){
TApplication *myapp=new TApplication("myapp",0,0);
TCanvas *c1 =new TCanvas("c1","Canvas Test",800,800);
c1->Connect("TCanvas", "Closed()", "TApplication",gApplication, "Terminate()");
myapp->Run();
return 0;
}
The code compiles without any warnings. The canvas opens when I run it. But when I close the the canvas, application doesn’t terminate and the terminal doesn’t prompt. Any suggestions ?
_ROOT Version: 6.20
_Platform: Ubuntu 20.04
_Compiler: g++
Thanks to #bellenot from root-forum for providing the following solution. Apparently, for ROOT 6 & above, This should be done with a TRootCanvas object.
#include "TROOT.h"
#include "TApplication.h"
#include "TCanvas.h"
#include "TRootCanvas.h"
int main()
{
TApplication *myapp = new TApplication("myapp", 0, 0);
TCanvas *c1 = new TCanvas("c1","Canvas Test",800,800);
TRootCanvas *rc = (TRootCanvas *)c1->GetCanvasImp();
rc->Connect("CloseWindow()", "TApplication", gApplication, "Terminate()");
myapp->Run();
return 0;
}
I am generating Pdf files using LibHaru libraries. My code is following
#include <iostream>
#include "hpdf.h"
using namespace std;
void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void *user_data)
{
}
int main()
{
cout<<"Compression"<<endl;
HPDF_Doc pdf = HPDF_New(error_handler, NULL);
if (!pdf)
return 0;
HPDF_STATUS Status = HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL);
return 0;
}
PROBLEM: I debugged the code and found that HPDF_SetCompressionMode() returns 4129, which is the error code for Invalid value set when invoking HPDF_SetCommpressionMode(). .
If you step into the code, you will see you are getting the error because the ZLIB compression library was not compiled into your copy of HaruPDF.
First: comment out this line in ..\win32\include\hpdf_config.h:
/* zlib is not available */
//#define LIBHPDF_HAVE_NOZLIB
Second: find, download and unzip the ZLIB code. You can obtain the source from the following Website:
http://www.zlib.net/
Third: tell HaruPDF where it can find the ZLIB code, and recompile HaruPDF.
You should now be able to use compression.
Ain't Open Source grand?
So I've been learning C++ and I've been trying to learn some SFML 2 via some videos. At first I had no real issues, I was using MS VS2012 and everything was fine. I start using MS VS2015 Community and it all starts going wrong and I've got no idea why!
Main problem:
Everything compiles, but it just crashes when I try to use sf::RenderWindow::createWindow()
Error Message:
I get the message "SFML_Project.exe is no longer working",
I go to debug it and it gives me the following message:
Unhandled exception thrown: read access violation.
this->_Ptr was 0xCCCCCCCC.
If there is a handler for this exception, the program may be safely continued.
and it does it on this function (some SFML code I know nothing about)
const facet *_Getfacet(size_t _Id) const
{ // look up a facet in locale object
const facet *_Facptr = _Id < _Ptr->_Facetcount
? _Ptr->_Facetvec[_Id] : 0; // null if id off end <- ON THIS LINE OF CODE IT BREAKS
if (_Facptr != 0 || !_Ptr->_Xparent)
return (_Facptr); // found facet or not transparent
else
{ // look in current locale
locale::_Locimp *_Ptr = _Getgloballocale();
return (_Id < _Ptr->_Facetcount
? _Ptr->_Facetvec[_Id] // get from current locale
: 0); // no entry in current locale
}
}
Line of info that was given at the Call Stack
sfml-system-d-2.dll!std::locale::_Getfacet(unsigned int _Id) Line 451 C++
My Code:
#include <iostream>
#include "SFML\Graphics.hpp"
int main()
{
sf::RenderWindow window;
window.create(sf::VideoMode(800, 800), "WindowName");
sf::Texture texture;
sf::Sprite sprite;
texture.loadFromFile("Player.png");
sprite.setTexture(texture);
sf::Event eventHandler;
while(window.isOpen())
{
while(window.pollEvent(eventHandler))
{
switch(eventHandler.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
window.clear();
window.draw(sprite);
window.display();
}
}
SFML version: Visual C++ 14 (2015) - 32-bit
Project Properties:
Debug -> C/C++ -> General -> Additional Include Directories:
$(SolutionDir)/SFML-2.3.2/include
Debug -> Linker -> General -> Additional Library Directories:
$(SolutionDir)/SFML-2.3.2/lib
Debug -> Linker -> Input -> Additional Dependencies:
sfml-main-d.lib
sfml-window-d.lib
sfml-graphics-d.lib
sfml-system-d.lib
sfml-network-d.lib
sfml-audio-d.lib
What I've tried:
I've tried turning all the dependencies from sfml-XX-d.lib to sfml-XX.lib files, which does allow me to create a window and draw shapes to that window, but then when I try to use sf::Texture::loadFromFile("filename") the console command window turns into the matrix and starts beeping.
It might be because you link the window lib before the graphics lib.
Try to move up the window lib under the graphics lib.
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
If it's still crashing, it may because your sfml's dlls does not match the current sfml version that you have. Happened to me once, I downloaded a new version of sfml without updating the binaries.
I am trying to run a sample code from the OpenNI 1.5 documentation.I have imported the library required XnCppWrapper.h so that I can use C++.The code has only one error on a particular variable "bshouldrun".I know that it should be declared as something but since I am new at this and the documentation does not contain anything above the main, I dont know what to declare it as..Please help!!
And thanks in advance.
#include <XnOpenNI.h>
#include <XnCppWrapper.h>
#include <stdio.h>
int main()
{
XnStatus nRetVal = XN_STATUS_OK;
xn::Context context;
// Initialize context object
nRetVal = context.Init();
// TODO: check error code
// Create a DepthGenerator node
xn::DepthGenerator depth;
nRetVal = depth.Create(context);
// TODO: check error code
// Make it start generating data
nRetVal = context.StartGeneratingAll();
// TODO: check error code
// Main loop
while (bShouldRun) //<-----------------------------**ERROR;bShouldRun Undefined**
{
// Wait for new data to be available
nRetVal = context.WaitOneUpdateAll(depth);
if (nRetVal != XN_STATUS_OK)
{
printf("Failed updating data: %s\n", xnGetStatusString(nRetVal));
continue;
}
// Take current depth map
const XnDepthPixel* pDepthMap = depth.GetDepthMap();
// TODO: process depth map
}
// Clean-up
context.Shutdown();
}
Here's what I did to run a sample from Visual Studio 2010 Express on Windows (8):
Opened the NiSimpleViewer.vcxproj VS2010 project from C:\Program Files (x86)\OpenNI\Samples\NiSimpleViewer
Edited OpenNI.rc to comment out #include "afxres.h" on line 10(might be missing this because I'm using Express version, not sure. Your machine might compile this fine/not complain about the missing header file)
Enabled Tools > Options > Debugging > Symbols > Microsoft Symbol Servers (to get past missing pdb files issue)
Optionally edit the SAMPLE_XML_PATH to "SamplesConfig.xml" rather than the default "../../../Data/SamplesConfig.xml", otherwise you need to run the sample executable from ..\Bin\Debug\NiSimpleViewer.exe by navigating to there rather than using the Ctrl+F5. A;so copy the SamplesConfig.xml file into your sample folder as you can see bellow
Here are a few images to illustrate some of the above steps:
You can also compile the NiHandTracker sample, which sounds closer to what you need.
So this explains the setup for OpenNI 1.5 which is what your question is about.
I've noticed your OpenNI 2 lib issue in the comments. It should be a matter of linking against SimpleHandTracker.lib which you can do via Project Properties (right-click project->select Properties) > Linker > Input > Additional Dependencies > Edit.
I don't have OpenNI2 setup on this machine, but assuming SimpleHandTracker.lib would be in OpenNI_INSTALL_FOLDER\Lib. Try a file search in case I might be wrong.