|
-
October 13th, 2005, 07:16 AM
#1
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
-
October 13th, 2005, 09:29 AM
#2
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
-
October 13th, 2005, 11:36 AM
#3
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.
-
October 13th, 2005, 11:42 AM
#4
Re: Urgent help needed in using log4cpp
 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.
 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
-
October 13th, 2005, 11:53 AM
#5
Re: Urgent help needed in using log4cpp
 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.
-
October 13th, 2005, 12:27 PM
#6
Re: Urgent help needed in using log4cpp
 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
-
October 13th, 2005, 06:56 PM
#7
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.
-
October 13th, 2005, 11:35 PM
#8
-
October 14th, 2005, 01:02 AM
#9
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.
-
October 14th, 2005, 01:11 AM
#10
Re: Urgent help needed in using log4cpp
 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
-
October 14th, 2005, 02:13 AM
#11
Re: Urgent help needed in using log4cpp
 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
-
October 14th, 2005, 04:03 AM
#12
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
-
October 14th, 2005, 04:19 AM
#13
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.
-
October 14th, 2005, 04:25 AM
#14
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
-
October 14th, 2005, 04:57 AM
#15
Re: Urgent help needed in using log4cpp
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|