#Understanding spdlog

1 messages · Page 1 of 1 (latest)

junior streamBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

#

@bronze salmon

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

unkempt lake
#

what does a project mean in this context?

bronze salmon
# unkempt lake what does a project mean in this context?

It is a full c++ project that I created with visual studio. Each project are composed by multiple classes.
What I want to say is the following. There is an App that invokes methods from the Project 1, 2 and 3. And these projects uses methods from a Common project.

#

We can also consider each project as an individual component. And the App invokes each component.
My goal is that each component contains logging. In this case, should I create a unique log instance for each component?
should the log variable for each component be shared between the different classes inside each component?

unkempt lake
#

Well it depends I would propably give them each their own instance

bronze salmon
#

I ask you this because I had project with "error LNK2019: unresolved external symbol" on the logging variable. I think the reason is that all projects are installed as lib, and the App is installed as a dll.

#

So, I don't know if this problem is my fault, or are we talking about c++ issue between dll and lib.

unkempt lake
#

shared_ptr is basically always a mistake

bronze salmon
#

And how to understand shared_ptr errors? I have an error like this, and I can't understand what I am doing wrong.

#

This is nothing related to logging, but it is the same error.

main.obj : error LNK2019: unresolved external symbol "public: __cdecl OctreeSegmentation::OctreeSegmentation(class std::shared_ptr<class ImageContainer>)" (??0OctreeSegmentation@@QEAA@V?$shared_ptr@VImageContainer@@@std@@@Z) referenced in function main [C:\Users\JumpStart\repo-git\segmentationcpp\OctreeSegmentation\apps\cmake-build-debug-visual-studio\main.vcxproj]
octreesegmentation_lib.lib(octreesegmentation.obj) : error LNK2019: unresolved external symbol "public: __cdecl PlaneDetectionPostprocessor::PlaneDetectionPostprocessor(void)" (??0PlaneDetectionPostprocessor@@QEAA@XZ) referenced in function "public: void __cdecl OctreeSegmentation::plane_postprocess(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?plane_postprocess@OctreeSegmentation@@QEAAXAEAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@1@Z) [C:\Users\JumpStart\repo-git\segmentationcpp\OctreeSegmentation\apps\cmake-build-debug-visual-studio\main.vcxproj]
C:\Users\JumpStart\repo-git\segmentationcpp\OctreeSegmentation\apps\cmake-build-debug-visual-studio\Debug\main.exe : fatal error LNK1120: 2 unresolved externals [C:\Users\JumpStart\repo-git\segmentationcpp\OctreeSegmentation\apps\cmake-build-debug-visual-studio\main.vcxproj]
#

what's going on here?

unkempt lake
#

most likely files are not being compiled correctly

#

that said im not sure from just this

bronze salmon
#

In a file segmentation.h (belongs to project A), I have the code

    ImageContainer(const std::string& ply_path,
                   const std::string& rgb_path,
                   const std::string& depth_path);
using ImageContainerPtr = std::shared_ptr<ImageContainer>;

In the file octreesegmentation.cpp (belongs to project B), I have the code:

OctreeSegmentation::OctreeSegmentation(ImageContainerPtr image) {    image_container = image;}

void
OctreeSegmentation::plane_postprocess(std::vector<std::string>& plane_tokens,
                                      std::string rgb_output_filename, std::string polygon_output_filename)
{
    PlaneDetectionPostprocessor plane_visualizer;
    std::cout << "Storing PNG with patches at " << rgb_output_filename << std::endl;
    std::cout << "Storing polygons info at " << polygon_output_filename << std::endl;
    plane_visualizer.visualize_plane_polygon(in_cloud, plane_tokens, rgb_output_filename, polygon_output_filename);
    return;
}

These projects compile sucessfully.

#

In the App, I have this snippet.

ImageContainer container = ImageContainer(input_filename, rgb_image_path, depth_image_path);
    ImageContainerPtr image_container = std::make_shared<ImageContainer>(container);
    OctreeSegmentation octreeSegmentation(image_container);
octreeSegmentation.plane_postprocess(plane_tokens, outputFileName, polygonFileName);
#

It seems that the problem is related to the shared_ptr<class ImageContainer>. I don't understand why?

#

is the example enough?

#

Project A and B are installed as a lib.

unkempt lake
#

im honestly not realy sure either, that said I would propably see if you can refractor this without a shared_ptr

bronze salmon
#

It seems than octreesegmentation_lib.lib(octreesegmentation.obj), which is Project A in this example, cannot find the reference to shared_ptr<ImageContainer>. Is this a problem from CMakeLists.txt, or should I have declared using ImageContainerPtr = std::shared_ptr<ImageContainer>; in the Project A?

#

in other words, I should have declared using ImageContainerPtr = std::shared_ptr<ImageContainer>; in Project A and B.

unkempt lake
#

hmmmm. if project B depends on project A it should be fine

bronze salmon
#

What I mean is that ImageContainer and the shared_ptr (ImageContainerPtr) is defined in Project B. Project A has a method that contains the argument ImageContainerPtr).

#

and the App creates a ImageContainer, that transforms it as a shared_ptr, and then invokes a method on project B and passses as an argument ImageContainerPtr variable:

    ImageContainer container = ImageContainer(input_filename, rgb_image_path, depth_image_path);
    ImageContainerPtr image_container = std::make_shared<ImageContainer>(container);
    OctreeSegmentation octreeSegmentation(image_container);
unkempt lake
#

I mean if the projects don't know about each other that could explain it

bronze salmon
#

what does this mean? Every project that uses the same shared_ptr, it should be declared the same shared_ptr on each project?

unkempt lake
#

well I meant as if projects depends on information in other projects but don't correctly link to each other

bronze salmon
#

In project B

class OctreeSegmentation {
private:
    ImageContainer image_container;
public:
    inline OctreeSegmentation(ImageContainer container);
...}

OctreeSegmentation::OctreeSegmentation(ImageContainer container)
        : image_container(container) {}
#

In the App

ImageContainer image_container = ImageContainer(input_filename, rgb_image_path, depth_image_path);
    OctreeSegmentation octreeSegmentation(image_container);
#

Unfortunately with this code, I have the error

main.obj : error LNK2019: unresolved external symbol "public: __cdecl OctreeSegmentation::OctreeSegmentation(class ImageContainer)" (??0OctreeSegmentation@@QEAA@VImageContainer@@@Z) referenced in function main [C:\Users\JumpStart\repo-git\segmentationcpp\OctreeSegmentation\apps\cmake-build-debug-visual-studio\main.vcxproj]
C:\Users\JumpStart\repo-git\segmentationcpp\OctreeSegmentation\apps\cmake-build-debug-visual-studio\Debug\main.exe : fatal error LNK1120: 1 unresolved externals [C:\Users\JumpStart\repo-git\segmentationcpp\OctreeSegmentation\apps\cmake-build-debug-visual-studio\main.vcxproj]
#

it is the same problem. In all CMakeLists.txt files I point to the project A.

#

but it seems that is not finding the reference to ImageContainer. Is this a problem of implementing the code, or a problem in the compilation?

#

the problem appears in the compilation of the App.

bronze salmon
#

Found the error.

#

The error was in the definition of OctreeSegmentation. "inline" keyword shouldn't be used.

junior streamBOT
#

@bronze salmon

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

bronze salmon
#

!solved