You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Alexandre Gacon <al...@masagroup.net> on 2005/07/22 14:56:24 UTC

Some problems with MSVC versions of Log4Cxx

Hello,

Several days ago I grabbed a CVS version of log4cxx 0.9.8. I built it with
Visual .Net without problem.

When I used it in my projects the lib works well but in debug mode I get
several memory leaks coming from log4cxx like

I wanted to try the examples given with log4cxx but I don't manage to
compile them with the generated project (visual 6 used).

Finally, in warning level 4, Visual produces the following warning:

..\..\..\include\log4cxx\helpers\appenderattachableimpl.h(45) : warning
C4251: 'log4cxx::helpers::AppenderAttachableImpl::appenderList' : class
'std::vector<_Ty>' needs to have dll-interface to be used by clients of
class 'log4cxx::helpers::AppenderAttachableImpl'
        with
        [
            _Ty=log4cxx::AppenderPtr
        ]

I don't know if it is linked to the leak problem.

Is it a bug or did I miss something in my projects configuration ?

For example the generated dsp for the examples defines some symbols for APR.
My projects work fine without them (I tried to compiler with them but I
still have the memory leaks).

Alexandre


RE : Some problems with MSVC versions of Log4Cxx

Posted by Alexandre Gacon <al...@masagroup.net>.
> I assume you have put log4cxx inside a LIB or DLL of yours, and then you
are using another project which references this LIB/DLL. Am I right?

You're right.

> I get this message in my DLL mentioned above.
> In my DLL, I put "#pragma warning(disable:4251)" and "#pragma
warning(default:4251)" around the member variable or function causing the
warning. This > will suppress the annoying messages.

> As far as I know, it is "safe" to ignore this warning.
> I receive the warning for anything which is used in the DLL, but not
exposed with "__declspec(dllexport)".

> In your case, "std::vector<_Ty>" is used by log4cxx, but not exposed to
clients of your LIB. You don't need to use "__declspec(dllexport)" in the >
variable/function which type is "std::vector<_Ty>", as far as it is an
internal log4cxx variable/function (now inside your LIB), and not used
directly > used by your client project.

But is this not a clue to find the memory leak ? Or is it Visual which can
not find where the desallocation is done ?

Alexandre


Re: Some problems with MSVC versions of Log4Cxx

Posted by Wagner Augusto Andreoli <wa...@gmail.com>.
This is my first post here, sorry if I somehow misunderstand the issue.
I'll just try to help from my (little) experience... ;)

I assume you have put log4cxx inside a LIB or DLL of yours, and then
you are using another project which references this LIB/DLL.
Am I right?

> When I used it in my projects the lib works well but in debug mode I get
> several memory leaks coming from log4cxx like

Kind of an "off-topic": I also have memory leaks in another VC++ .NET
project of mine, which uses a DLL project, also written by me, also in
VC++ .NET.
I don't know yet how to find the leaks.
I hope this log4cxx topic will help me...

Now back to the topic. ;)

> I wanted to try the examples given with log4cxx but I don't manage to
> compile them with the generated project (visual 6 used).

I don't know if you have (had) this problem too, but...
I once tried to use the VC project files include in log4cxx.
My version of Visual C++ .NET is 7.0, but the log4cxx files version is 7.1.
It didn't work.
So I had to open the VC++ 6 files (.dsp and .dsw), and my VC.NET 7.0
converted them properly.

> Finally, in warning level 4, Visual produces the following warning:
> 
> ..\..\..\include\log4cxx\helpers\appenderattachableimpl.h(45) : warning
> C4251: 'log4cxx::helpers::AppenderAttachableImpl::appenderList' : class
> 'std::vector<_Ty>' needs to have dll-interface to be used by clients of
> class 'log4cxx::helpers::AppenderAttachableImpl'
>         with
>         [
>             _Ty=log4cxx::AppenderPtr
>         ]
> 
> I don't know if it is linked to the leak problem.

I get this message in my DLL mentioned above.
In my DLL, I put "#pragma warning(disable:4251)" and "#pragma
warning(default:4251)" around the member variable or function causing
the warning.
This will suppress the annoying messages.

As far as I know, it is "safe" to ignore this warning.
I receive the warning for anything which is used in the DLL, but not
exposed with "__declspec(dllexport)".

In your case, "std::vector<_Ty>" is used by log4cxx, but not exposed
to clients of your LIB.
You don't need to use "__declspec(dllexport)" in the variable/function
which type is "std::vector<_Ty>", as far as it is an internal log4cxx
variable/function (now inside your LIB), and not used directly used by
your client project.

I hope I was clear enough to be understood... ;)

Best regards for all,
Wagner