CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2010
    Posts
    50

    Linker error while connecting static library with DLL

    I have a static library in which class with log4net is defined.something like this -

    public ref class CustomLog
    {
    public:
    static log4net::ILog^ m_logger;

    log4net::ILog^ SetLogger();
    };

    This static library is then used to connect to another C++ DLL - I have added header file used for this log class in C++ DLL also added static library reference in additional dependency.WHen I ma trying to compile this DLL getting following linking error -

    error LNK2020: unresolved token (06000003) CustomLog::SetLogger


    Please let me know how to resolve this issue.

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Linker error while connecting static library with DLL

    Hmmm... CustomLog is a class you wrote yourself? Looks like you simply declared CustomLog::SetLogger() but didn't define it. So, not actually a problem with the 3rd-party library in this case.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Jun 2010
    Posts
    50

    Re: Linker error while connecting static library with DLL

    I had defination as well.This static library builds succesfully,but when trying build another C++ DLL throws linker error.Here is defination of SetLogger().

    log4net::ILog^ CustomLog::SetLogger()
    {
    String^ str = "CustomLoger";
    CustomLog::m_logger = log4net::LogManager::GetLogger(str);
    return CustomLog::m_logger;
    }

    Any thoughts??

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Linker error while connecting static library with DLL

    Quote Originally Posted by forstudy3 View Post
    Any thoughts??
    Not really sophisticated ones at the moment, I must admit.

    Are you sure the source file containing this definition actually gets compiled and takes part in the linking process (IOW maybe incorrect project settÃ*ngs)? Does that module define other functions that are used from other modules about which the linked does not complain?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Jun 2010
    Posts
    50

    Re: Linker error while connecting static library with DLL

    Yes ,it has many other modules and methods.Linker only complains about this class.

  6. #6
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Linker error while connecting static library with DLL

    Well, I'm a bit out of ideas now so I did an MSDN search hoping to find some inspiration. (Did you try this too?)

    Just a shot in the dark: Could it be something really silly like forgetting to qualify the class name when defining the function like in this thread on MSDN: http://social.msdn.microsoft.com/For...e-33caeff5aaad? (To mitigate the embarrassment incurred by this a bit: This happens to me too from time to time... )

    Aside from that I can only recommend an MSDN search (and as plan B a Google search) for now. Since in my tests to reproduce the problem I always got a 06000001 as part of the error message instead of your 06000003, I tried to restrict the search by specifying the number you got as an additional search criterion. I don't think that gains much though. It seems this number is just an internal number used by the linker to identify the token, so it's arbitrary, not further specifying the cause of the error.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured