CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    May 2002
    Location
    India
    Posts
    268

    Red face Urgent help needed in using log4cpp


    Hi,
    I have downloaded log4cpp and am facing two problems.
    First Problem
    I built the log4cpp in VC 7.0 as MDd in debug version. I put log4cppD.dll & log4cppD.lib in my debug folder. When I try to link it to my static library, it is giving the following linking errors (614 in total). My atatic library is also built as MDd in debug verison.

    Code:
    log4cppD.lib(log4cppD.dll) : warning LNK4006: "public: int __thiscall log4cpp::CategoryStream::width(int)" (?width@CategoryStream@log4cpp@@QAEHH@Z) already defined in log4cppD.lib(log4cppD.dll); second definition ignored
    ....
    ....
    log4cppD.lib(log4cppD.dll) : warning LNK4006: "public: static void __cdecl log4cpp::Category::setRootPriority(int)" (?setRootPriority@Category@log4cpp@@SAXH@Z) already defined in log4cppD.lib(log4cppD.dll); second definition ignored
    ....
    ....
    log4cppD.lib(log4cppD.dll) : warning LNK4006: "__declspec(dllimport) public: virtual void __thiscall log4cpp::NTEventLogAppender::setLayout(class log4cpp::Layout *)" (__imp_?setLayout@NTEventLogAppender@log4cpp@@UAEXPAVLayout@2@@Z) already defined in log4cppD.lib(log4cppD.dll); second definition ignored
    ....
    ...
    log4cppD.lib(log4cppD.dll) : warning LNK4006: "__declspec(dllimport) protected: void __thiscall log4cpp::NTEventLogAppender::regSetDword(struct HKEY__ *,char *,unsigned long)" (__imp_?regSetDword@NTEventLogAppender@log4cpp@@IAEXPAUHKEY__@@PADK@Z) already defined in log4cppD.lib(log4cppD.dll); second definition ignored
    .......
    ....
    log4cppD.lib(log4cppD.dll) : warning LNK4006: "public: __thiscall log4cpp::AbortAppender::AbortAppender(class log4cpp::AbortAppender const &)" (??0AbortAppender@log4cpp@@QAE@ABV01@@Z) already defined in log4cppD.lib(log4cppD.dll); second definition ignored
    ...
    log4cppD.lib(log4cppD.dll) : warning LNK4006: __IMPORT_DESCRIPTOR_log4cppD already defined in log4cppD.lib(log4cppD.dll); second definition ignored
    Can anyone please tell me why am I getting these linking errors and how to resolve the same?


    Second Problem
    When I try to use the log4cpp in VC 6.0, I get the errors
    Code:
    d:\log4cpp-0.3.5rc1\include\log4cpp\priority.hh(65) : error C2258: illegal pure syntax, must be '= 0'
    d:\log4cpp-0.3.5rc1\include\log4cpp\priority.hh(65) : error C2252: 'MESSAGE_SIZE' : pure specifier can only be specified for functions
    d:\log4cpp-0.3.5rc1\include\log4cpp\threading\msthreads.hh(160) : fatal error C1506: unrecoverable block scoping error
    Please help me on this too.

    Also please help in using log4cpp with MFC dialog based applications. I am not certain of the type of runtime library i need to set.
    Last edited by The Saint; October 13th, 2005 at 07:21 AM. Reason: Add to query
    Life is short, enjoy it with a smile as long as it lasts.
    User error. Replace User and press any key when ready. - Anonymous

  2. #2
    Join Date
    Sep 2004
    Posts
    561

    Re: Urgent help needed in using log4cpp

    Here's what you can do in Visual Studio 6.0.

    Go to the "build" tab at the bottom of the editor where you see the errors occur. To figure out what was wrong highlight one of errors in bold. Press "F1". You'll find a definition of the error.

    4cpp\priority.hh(65) : error C2258: illegal pure syntax, must be '= 0'
    4cpp\priority.hh(65) : error C2252: 'MESSAGE_SIZE' : pure

  3. #3
    Join Date
    Jan 2001
    Posts
    588

    Re: Urgent help needed in using log4cpp

    With regard to your first problem, you didn't show any linker errors. Those are all warnings, so it's possible that your code could have built just fine.

  4. #4
    Join Date
    May 2002
    Location
    India
    Posts
    268

    Re: Urgent help needed in using log4cpp

    Quote Originally Posted by Rigel
    Here's what you can do in Visual Studio 6.0.

    Go to the "build" tab at the bottom of the editor where you see the errors occur. To figure out what was wrong highlight one of errors in bold. Press "F1". You'll find a definition of the error.
    Thank you. I am aware of that. But what I want to know is, how safe would it be to comment this and build the lib.

    Quote Originally Posted by Bob Davis
    With regard to your first problem, you didn't show any linker errors. Those are all warnings, so it's possible that your code could have built just fine.

    They are warnings as long as I do not call any function from the library. nce I try to get an instance of category or configure the SimpleConfigurator, then I get compilation errors.
    Last edited by The Saint; October 13th, 2005 at 11:45 AM.
    Life is short, enjoy it with a smile as long as it lasts.
    User error. Replace User and press any key when ready. - Anonymous

  5. #5
    Join Date
    Sep 2004
    Posts
    561

    Re: Urgent help needed in using log4cpp

    Quote Originally Posted by The Saint
    Thank you. I am aware of that. But what I want to know is, how safe would it be to comment this and build the lib.
    Why not just fix the problem? It's a very simple fix.
    Why would you want to comment out something that is potentially important to the library? I wouldn't comment anything out unless I knew full well commenting it out would have any drastic consequences.

  6. #6
    Join Date
    May 2002
    Location
    India
    Posts
    268

    Re: Urgent help needed in using log4cpp

    Quote Originally Posted by Rigel
    Why not just fix the problem? It's a very simple fix.
    Why would you want to comment out something that is potentially important to the library? I wouldn't comment anything out unless I knew full well commenting it out would have any drastic consequences.
    Hi mate,
    Well I meant that I am aware of how to get to the definiton of the error. My query was on how to solve the error which does not occur in VC7.
    Life is short, enjoy it with a smile as long as it lasts.
    User error. Replace User and press any key when ready. - Anonymous

  7. #7
    Join Date
    Jan 2004
    Posts
    206

    Re: Urgent help needed in using log4cpp

    Hi Saint,

    How about u zip up the code (together with the lib and dll) and post it up here? That would be easier for ppl to try it out and solve ur problems, instead of guessing the causes of the errors.

  8. #8
    Join Date
    May 2002
    Location
    India
    Posts
    268

    Re: Urgent help needed in using log4cpp

    Hi,
    I am attaching the files for your reference. The Log4CPP.zip contains the source code that I am using to build the log4cpp dll & library.

    Mailslots.zip contains my static library. In the file CommonDefs.h under Mailslots, if you comment out

    Code:
    log4cpp::SimpleConfigurator::configure("..\\log\\log4cpp.init");
    log4cpp::Category& g_Log = log4cpp::Category::getInstance("Mailslots");
    then it will generate the 600+ linker warnings. When these lines are added it generates compilation errors.


    Please let me know how to solve this as I am on a tight schedule to finish this.
    Attached Files Attached Files
    Life is short, enjoy it with a smile as long as it lasts.
    User error. Replace User and press any key when ready. - Anonymous

  9. #9
    Join Date
    Jan 2004
    Posts
    206

    Re: Urgent help needed in using log4cpp

    Hi Saint,

    It would be better if you provide the actual environment under MS Visual Studio 6. The only .dsw file you provide is msvc6.dsw, but majority of the projects (*.dsp) under it cannot be found. Under the mailslot folder is only the solution file which cannot be openned under vs6.

  10. #10
    Join Date
    May 2002
    Location
    India
    Posts
    268

    Re: Urgent help needed in using log4cpp

    Quote Originally Posted by Wombat
    Hi Saint,

    It would be better if you provide the actual environment under MS Visual Studio 6. The only .dsw file you provide is msvc6.dsw, but majority of the projects (*.dsp) under it cannot be found. Under the mailslot folder is only the solution file which cannot be openned under vs6.
    Hi Wombat,
    The log4cpp is the latest version. I uploaded only the relevant files due to size constraint.


    My project is in VC7 and hence the mailsot solution too is in VC7.
    Life is short, enjoy it with a smile as long as it lasts.
    User error. Replace User and press any key when ready. - Anonymous

  11. #11
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Urgent help needed in using log4cpp

    Quote Originally Posted by The Saint
    Hi Wombat,
    The log4cpp is the latest version. I uploaded only the relevant files due to size constraint.
    But are these *all* the files needed to reproduce the compiler error?

    No one, unless they have a lot of time, will do a search on the internet to find "log4cpp", download a library, install a library, set up an environment, etc., etc. to reproduce a compiler error. You need to provide all the information and preferably all the files that reproduce the error.

    Regards,

    Paul McKenzie

  12. #12
    Join Date
    May 2002
    Location
    India
    Posts
    268

    Re: Urgent help needed in using log4cpp

    Hi Paul,
    True that no one would do a search on the internet to find "log4cpp", download a library, install a library, set up an environment, etc., etc. to reproduce a compiler error.

    I could not upload the library as it is more than the allowed 250 KB upload limit here.

    So the next best thing I could do was give the source which can be built. There is a .dsp file which can be attached to a .dsw file in VC6 and a .sln file for VC7.

    The other files/.dsp that is being referred here are not for log4cpp library. They are samples that come along with the log4cpp workspace.

    This is the best that I could give. If you feel that I could provide more information in any other way do guide me.
    Life is short, enjoy it with a smile as long as it lasts.
    User error. Replace User and press any key when ready. - Anonymous

  13. #13
    Join Date
    Jan 2004
    Posts
    206

    Re: Urgent help needed in using log4cpp

    Hi Saint,

    I tried to compile your log4cpp project under vs6 and manage to get the same errors as yours. And the culprit is the following line in priority.hh:

    Code:
        class LOG4CPP_EXPORT Priority {
            public:
    		static const int MESSAGE_SIZE=8;
    
    ///// Some other declarations //////
    };
    You can't initialize variables inside a class in this manner. The compiler mistaken it as a pure virtual function declaration, and thus generates the errors.

    To solve, take out the initialization portion:
    Code:
    static const int MESSAGE_SIZE;
    If you need to initialize it to a value other than 0, do it at file scope inside priority.cpp :

    Code:
    #include "PortabilityImpl.hh"
    #include <log4cpp/Priority.hh>
    #include <cstdlib>
    
    const int log4cpp::Priority::MESSAGE_SIZE=8;
    It should be able to compile successfully.

  14. #14
    Join Date
    May 2002
    Location
    India
    Posts
    268

    Re: Urgent help needed in using log4cpp

    Thanks you very much wombat. I wonder how I missed that. So stupid of me.

    Actually I have been engrossed with the linking issue that when my mate came to me with this error I just did not realize it.

    Thank you again. Can you please help me on the other problem?
    Life is short, enjoy it with a smile as long as it lasts.
    User error. Replace User and press any key when ready. - Anonymous

  15. #15
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Urgent help needed in using log4cpp

    Quote Originally Posted by Wombat
    You can't initialize variables inside a class in this manner. The compiler mistaken it as a pure virtual function declaration, and thus generates the errors.
    To be more clear, you can't do this with Visual C++ 6.0, but it is perfectly valid C++ syntax.

    Saint (and Wombat), the issue is that Visual C++ 6.0 does not support all of the modern C++ syntax. If you get a third-party library, make sure it clearly states that it was compiled using Visual C++ 6.0 before wasting time getting it to work on VC 6.0. If not, you will more than likely get problems such as this, since the original coders of the library were using more up-to-date ANSI compliant C++ compilers when developing the library.

    Regards,

    Paul McKenzie

Page 1 of 2 12 LastLast

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