plz help i was stuck with the error for 2 days

Haicerikas 26 Reputation points
2021-03-09T12:00:53.177+00:00

these errors keep appearing

-------------------------------------------------------------------------------------------------------------------------------

LNK2001: unresolved external symbol "private: static class std::shared_ptr<class spdlog::logger> Luing::Log::s_CoreLogger" (?s_CoreLogger@Loughborough @Luing@@0V?$shared_ptr@Vlogger@spdlog@@@std@@A)

-------------------------------------------------------------------------------------------------------------------------------

LNK2001: unresolved external symbol "private: static class std::shared_ptr<class spdlog::logger> Luing::Log::s_ClientLogger" (?s_ClientLogger@Loughborough @Luing@@0V?$shared_ptr@Vlogger@spdlog@@@std@@A)

-------------------------------------------------------------------------------------------------------------------------------

plz help

Developer technologies | Visual Studio | Other
{count} vote

3 answers

Sort by: Most helpful
  1. Viorel 122.6K Reputation points
    2021-03-09T14:55:58.767+00:00

    Probably you must add these lines to any .cpp file:

    namespace Luing
    {
        std::shared_ptr<spdlog::logger> Log::s_CoreLogger;
    }
    

    Give details about Luing, Log, s_CoreLogger if it does not help.

    It is also possible to use a new form of inline.

    0 comments No comments

  2. Michael Taylor 60,331 Reputation points
    2021-03-09T14:56:39.367+00:00

    You are using C++ to call some library that has a Luing::Log class. You have included the appropriate header file so the compiler can find the definition and compile. However during the linking phase when the linker is looking for the actual implementation it cannot find it and fails the call with the given error. In most cases you are missing a LIB reference in your linker settings. Go to the linker settings in your project and then to the Input tab. Under Additional Dependencies is the list of LIB files that are linked. You need to ensure that whatever library you're using is in this list. Note that the dependencies are per configuration/platform so you'll need to do this for each of your mappings.

    75908-image.png

    You might also consider looking to see if the library is provided via vcpkg. If so then that would be the preferred route.


  3. Firdeus Kasaj 1 Reputation point
    2022-04-14T21:00:23.38+00:00

    Did you find the solution?
    Please help me!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.