[ 
https://issues.apache.org/jira/browse/LOGCXX-528?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Russel Miranda updated LOGCXX-528:
----------------------------------
    Description: 
With:
 * CMake 3.13.4,
 * g++ 4.8.5
 * Boost 1.53.0
 ** thread
 ** chrono
 ** system
 ** date_time
 ** atomic
 * apr-1.6.2
 * apr-devel-1.6.2
 * apr-util-1.6.0
 * apr-util-devel-1.6.0

CMake fails to properly detect the Boost threads package, due to a link error 
in the test build. There is no indication of a problem at the CMake stage other 
than the lack of output for the shared_mutex implementation:

{{log4cxx configuration summary:}}
 {{Build shared library ............ : ON}}
 {{Build tests ..................... : ON}}
 {{Build site ...................... : OFF}}
 {{Install prefix .................. : /usr/local}}
 {{C++ compiler .................... : /usr/bin/c++}}
 {{log4cxx char API ................ : utf-8}}
 {{log4cxx wchar API ............... : ON}}
 {{log4cxx unichar API ............. : OFF}}
 {{logchar type .................... : utf-8}}
 {{charset ......................... : locale}}
 {{Using libESMTP .................. : OFF}}
 {{ODBC library .................... : OFF}}
 {{syslog .......................... : ON}}
 {{Qt support ...................... : OFF}}
 {{shared_mutex implementation ..... :}}

This can be fixed by adding "-lboost_system" to CMAKE_CXX_FLAGS.

After correcting the CMake problem, a make may be performed, which results in 
the compiler complaining that mutex is not  found in the std:: namespace in a 
number of places. This can be rectified by adding "#include <mutex>" to:
 * log4cxx/src/main/include/log4cxx/helpers/appenderattachableimpl.h
 * log4cxx/src/main/include/log4cxx/helpers/aprinitializer.h
 * log4cxx/src/main/include/log4cxx/helpers/loglog.h
 * log4cxx/src/main/include/log4cxx/helpers/serversocket.h
 * log4cxx/src/main/include/log4cxx/level.h
 * log4cxx/src/main/include/log4cxx/rolling/action.h

This may not be a minimal set, but it was sufficient to satisfy the build.

Once these problems have been addressed, the compiler complains that the C++17 
feature "std::weak_from_this()" is not available. It is used in two places in 
log4cxx/src/main/cpp/hierarchy.cpp: line 226 and line 426.

It may be preferable to create a local routine that stands in for 
"std::weak_from_this()", but I found it sufficient to just #if / #else / #endif 
around the single line in each location that called weak_from_this() and 
replace it with a two-step version similar to this:

{{{{std::weak_ptr<Hierarchy> weak_handle = shared_from_this();}}}}
{{logger->setHierarchy(weak_handle);}}

in place of the single-step:

{{logger->setHierarchy(weak_from_this());}}

I used the precompiler test:

{{#if __cplusplus >= 201500L}}

That was sufficient to differentiate my g++ 4.8.5 from more modern compilers 
that support C++17, but there may be more precise ways of achieving this end - 
I just don't have the ability to test on anything other than g++ 4.8.5.

After making this change the build should complete successfully, and all 60/60 
tests should pass.

NOTE: Because g++ 4.8.5 does not support std::shared_mutex and is therefore 
dependent on Boost thread, and Boost thread itself is dependent on Boost 
system, it was required to link executables using this version of log4cxx w/ 
Boost system as well. I suspect there may be Boost compile-time flags that 
might make that unnecessary, but my knowledge of Boost is not sufficient to 
achieve that goal.

 

  was:
With:
 * CMake 3.13.4,
 * g++ 4.8.5
 * Boost 1.53.0
 ** thread
 ** chrono
 ** system
 ** date_time
 ** atomic
 * apr-1.6.2
 * apr-devel-1.6.2
 * apr-util-1.6.0
 * apr-util-devel-1.6.0

CMake fails to properly detect the Boost threads package, due to a link error 
in the test build. There is no indication of a problem at the CMake stage other 
than the lack of output for the shared_mutex implementation:

{{log4cxx configuration summary:}}
{{Build shared library ............ : ON}}
{{Build tests ..................... : ON}}
{{Build site ...................... : OFF}}
{{Install prefix .................. : /usr/local}}
{{C++ compiler .................... : /usr/bin/c++}}
{{log4cxx char API ................ : utf-8}}
{{log4cxx wchar API ............... : ON}}
{{log4cxx unichar API ............. : OFF}}
{{logchar type .................... : utf-8}}
{{charset ......................... : locale}}
{{Using libESMTP .................. : OFF}}
{{ODBC library .................... : OFF}}
{{syslog .......................... : ON}}
{{Qt support ...................... : OFF}}
{{shared_mutex implementation ..... :}}

This can be fixed by adding "-lboost_system" to CMAKE_CXX_FLAGS.

After correcting the CMake problem, a make may be performed, which results in 
the compiler complaining that mutex is not  found in the std:: namespace in a 
number of places. This can be rectified by adding "#include <mutex>" to:
 * log4cxx/src/main/include/log4cxx/helpers/appenderattachableimpl.h
 * log4cxx/src/main/include/log4cxx/helpers/aprinitializer.h
 * log4cxx/src/main/include/log4cxx/helpers/loglog.h
 * log4cxx/src/main/include/log4cxx/helpers/serversocket.h
 * log4cxx/src/main/include/log4cxx/level.h
 * log4cxx/src/main/include/log4cxx/rolling/action.h

This may not be a minimal set, but it was sufficient to satisfy the build.

Once these problems have been addressed, the compiler complains that the C++17 
feature "std::weak_from_this()" is not available. It is used in two places in 
log4cxx/src/main/cpp/hierarchy.cpp: line 226 and line 426.

It may be preferable to create a local routine that stands in for 
"std::weak_from_this()", but I found it sufficient to just #if / #else / #endif 
around the single line in each location that called weak_from_this() and 
replace it with a two-step version similar to this:

{{std::weak_ptr<Hierarchy> weak_handle = shared_from_this();}}
{{ logger->setHierarchy(weak_handle);}}

in place of the single-step:

{{logger->setHierarchy(weak_from_this());}}

I used the precompiler test:

{{#if __cplusplus >= 201500L}}

That was sufficient to differentiate my g++ 4.8.5 from more modern compilers 
that support C++17, but there may be more precise ways of achieving this end - 
I just don't have the ability to test on anything other than g++ 4.8.5.

After making this change the build should complete successfully, and all 60/60 
tests should pass.

NOTE: Because g++ 4.8.5 does not support std::shared_mutex and is therefore 
dependent on Boost thread, and Boost thread itself is dependent on Boost 
system, it was required to link executables using this version of log4cxx w/ 
Boost system as well. I suspect there may be Boost compile-time flags that 
might make that unnecessary, but my knowledge of Boost is not sufficient to 
achieve that goal.

 


> log4cxx fails to build on Centos 7.6
> ------------------------------------
>
>                 Key: LOGCXX-528
>                 URL: https://issues.apache.org/jira/browse/LOGCXX-528
>             Project: Log4cxx
>          Issue Type: Bug
>    Affects Versions: 0.12.0
>            Reporter: Russel Miranda
>            Priority: Major
>
> With:
>  * CMake 3.13.4,
>  * g++ 4.8.5
>  * Boost 1.53.0
>  ** thread
>  ** chrono
>  ** system
>  ** date_time
>  ** atomic
>  * apr-1.6.2
>  * apr-devel-1.6.2
>  * apr-util-1.6.0
>  * apr-util-devel-1.6.0
> CMake fails to properly detect the Boost threads package, due to a link error 
> in the test build. There is no indication of a problem at the CMake stage 
> other than the lack of output for the shared_mutex implementation:
> {{log4cxx configuration summary:}}
>  {{Build shared library ............ : ON}}
>  {{Build tests ..................... : ON}}
>  {{Build site ...................... : OFF}}
>  {{Install prefix .................. : /usr/local}}
>  {{C++ compiler .................... : /usr/bin/c++}}
>  {{log4cxx char API ................ : utf-8}}
>  {{log4cxx wchar API ............... : ON}}
>  {{log4cxx unichar API ............. : OFF}}
>  {{logchar type .................... : utf-8}}
>  {{charset ......................... : locale}}
>  {{Using libESMTP .................. : OFF}}
>  {{ODBC library .................... : OFF}}
>  {{syslog .......................... : ON}}
>  {{Qt support ...................... : OFF}}
>  {{shared_mutex implementation ..... :}}
> This can be fixed by adding "-lboost_system" to CMAKE_CXX_FLAGS.
> After correcting the CMake problem, a make may be performed, which results in 
> the compiler complaining that mutex is not  found in the std:: namespace in a 
> number of places. This can be rectified by adding "#include <mutex>" to:
>  * log4cxx/src/main/include/log4cxx/helpers/appenderattachableimpl.h
>  * log4cxx/src/main/include/log4cxx/helpers/aprinitializer.h
>  * log4cxx/src/main/include/log4cxx/helpers/loglog.h
>  * log4cxx/src/main/include/log4cxx/helpers/serversocket.h
>  * log4cxx/src/main/include/log4cxx/level.h
>  * log4cxx/src/main/include/log4cxx/rolling/action.h
> This may not be a minimal set, but it was sufficient to satisfy the build.
> Once these problems have been addressed, the compiler complains that the 
> C++17 feature "std::weak_from_this()" is not available. It is used in two 
> places in log4cxx/src/main/cpp/hierarchy.cpp: line 226 and line 426.
> It may be preferable to create a local routine that stands in for 
> "std::weak_from_this()", but I found it sufficient to just #if / #else / 
> #endif around the single line in each location that called weak_from_this() 
> and replace it with a two-step version similar to this:
> {{{{std::weak_ptr<Hierarchy> weak_handle = shared_from_this();}}}}
> {{logger->setHierarchy(weak_handle);}}
> in place of the single-step:
> {{logger->setHierarchy(weak_from_this());}}
> I used the precompiler test:
> {{#if __cplusplus >= 201500L}}
> That was sufficient to differentiate my g++ 4.8.5 from more modern compilers 
> that support C++17, but there may be more precise ways of achieving this end 
> - I just don't have the ability to test on anything other than g++ 4.8.5.
> After making this change the build should complete successfully, and all 
> 60/60 tests should pass.
> NOTE: Because g++ 4.8.5 does not support std::shared_mutex and is therefore 
> dependent on Boost thread, and Boost thread itself is dependent on Boost 
> system, it was required to link executables using this version of log4cxx w/ 
> Boost system as well. I suspect there may be Boost compile-time flags that 
> might make that unnecessary, but my knowledge of Boost is not sufficient to 
> achieve that goal.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to