You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Robert Middleton (Jira)" <lo...@logging.apache.org> on 2021/07/09 02:45:01 UTC
[jira] [Commented] (LOGCXX-528) log4cxx fails to build on Centos
7.6 / g++ 4.8.5 / Boost 1.53
[ https://issues.apache.org/jira/browse/LOGCXX-528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17377727#comment-17377727 ]
Robert Middleton commented on LOGCXX-528:
-----------------------------------------
This is rather interesting. I'm using a different VM from what I normally develop on, and setting the C++ standard to 11 allows be to recreate the issue with not detecting Boost with GCC 8.3.0 and CMake 3.13.4. I think my normal development VM is setup to use a newer version of CMake.
The setHierarchy using weak_from_this is also rather interesting: by default, CMake will by default try to use gnu+\+11 for the standard, instead of c+\+11. Because there are some GNU extensions activated at that point, weak_from_this is available, even though it is not actually part of the official C+\+11 standard. You can see the [CXX_EXTENSIONS|https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html#prop_tgt:CXX_EXTENSIONS] property for some more information.
Anyway, I've made a branch/PR with these fixes. If you are able to test and see if they work on your side, that would be helpful: https://github.com/apache/logging-log4cxx/pull/66
> log4cxx fails to build on Centos 7.6 / g++ 4.8.5 / Boost 1.53
> -------------------------------------------------------------
>
> 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
> Assignee: Robert Middleton
> 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)