geirg71 opened a new issue, #177:
URL: https://github.com/apache/logging-log4cxx/issues/177
I originally found this issue when compiling log4cxx 1.0.0 as a DLL in the
MSYS2 environment on Windows, using GCC 12. It is however a general problem and
can be easily reproduced with GCC on Linux, as follows.
Change LOG4CXX_INSTANTIATE_EXPORTED_PTR in
src/main/include/log4cxx/log4cxx.h.in to make it identical as for the Win32/DLL
case. That is:
Change
`#define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T)`
to
`#define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class LOG4CXX_EXPORT
std::shared_ptr<T>`
Compiling on Ubuntu 22.04 with GCC 11:
```
$ gcc --version
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cmake --build cmake_build --target install --config RelWithDebInfo
--parallel
Checking configuration
[ 0%] Built target configure_log4cxx
Consolidate compiler generated dependencies of target log4cxx
[ 2%] Building CXX object src/main/cpp/CMakeFiles/log4cxx.dir/class.cpp.o
[ 2%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/defaultconfigurator.cpp.o
[ 3%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/domconfigurator.cpp.o
[ 4%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/filterbasedtriggeringpolicy.cpp.o
[ 5%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/inputstreamreader.cpp.o
[ 6%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/optionconverter.cpp.o
[ 6%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/properties.cpp.o
[ 7%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/propertyconfigurator.cpp.o
[ 8%] Building CXX object
src/main/cpp/CMakeFiles/log4cxx.dir/propertysetter.cpp.o
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/inputstreamreader.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::InputStream>’ in
namespace ‘log4cxx::helpers’ (which does not enclose namespace ‘std’)
[-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/helpers/inputstreamreader.h:32:1: note: in
expansion of macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
32 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(InputStream);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::CharsetDecoder>’ in
namespace ‘log4cxx::helpers’ (which does not enclose namespace ‘std’)
[-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/helpers/inputstreamreader.h:33:1: note: in
expansion of macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
33 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(CharsetDecoder);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/propertysetter.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::Object>’ in namespace
‘log4cxx::helpers’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/config/propertysetter.h:30:1: note: in expansion of
macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
30 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(Object);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:762:
src/main/cpp/CMakeFiles/log4cxx.dir/inputstreamreader.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/properties.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::InputStream>’ in
namespace ‘log4cxx::helpers’ (which does not enclose namespace ‘std’)
[-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/helpers/inputstreamreader.h:32:1: note: in
expansion of macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
32 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(InputStream);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::CharsetDecoder>’ in
namespace ‘log4cxx::helpers’ (which does not enclose namespace ‘std’)
[-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/helpers/inputstreamreader.h:33:1: note: in
expansion of macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
33 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(CharsetDecoder);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:1392:
src/main/cpp/CMakeFiles/log4cxx.dir/properties.cpp.o] Error 1
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/filterbasedtriggeringpolicy.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::spi::Filter>’ in namespace
‘log4cxx::rolling’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h:39:1: note:
in expansion of macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
39 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(log4cxx::spi::Filter);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:636:
src/main/cpp/CMakeFiles/log4cxx.dir/filterbasedtriggeringpolicy.cpp.o] Error 1
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/propertyconfigurator.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::Object>’ in namespace
‘log4cxx::helpers’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/config/propertysetter.h:30:1: note: in expansion of
macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
30 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(Object);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/optionconverter.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::Object>’ in namespace
‘log4cxx::helpers’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/config/propertysetter.h:30:1: note: in expansion of
macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
30 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(Object);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:1448:
src/main/cpp/CMakeFiles/log4cxx.dir/propertysetter.cpp.o] Error 1
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/domconfigurator.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::Object>’ in namespace
‘log4cxx::helpers’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/config/propertysetter.h:30:1: note: in expansion of
macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
30 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(Object);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/defaultconfigurator.cpp:17:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::Object>’ in namespace
‘log4cxx::helpers’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/config/propertysetter.h:30:1: note: in expansion of
macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
30 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(Object);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:1280:
src/main/cpp/CMakeFiles/log4cxx.dir/optionconverter.cpp.o] Error 1
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::spi::Filter>’ in namespace
‘log4cxx::rolling’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h:39:1: note:
in expansion of macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
39 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(log4cxx::spi::Filter);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:426:
src/main/cpp/CMakeFiles/log4cxx.dir/defaultconfigurator.cpp.o] Error 1
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:1420:
src/main/cpp/CMakeFiles/log4cxx.dir/propertyconfigurator.cpp.o] Error 1
In file included from src/main/include/log4cxx/logstring.h:22,
from src/main/cpp/class.cpp:18:
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::spi::Filter>’ in namespace
‘log4cxx::rolling’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/rolling/filterbasedtriggeringpolicy.h:39:1: note:
in expansion of macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
39 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(log4cxx::spi::Filter);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmake_build/src/main/include/log4cxx/log4cxx.h:94:80: error: explicit
instantiation of ‘class std::shared_ptr<log4cxx::helpers::Object>’ in namespace
‘log4cxx::helpers’ (which does not enclose namespace ‘std’) [-fpermissive]
94 | #define LOG4CXX_INSTANTIATE_EXPORTED_PTR(T) template class
LOG4CXX_EXPORT std::shared_ptr<T>
|
^~~~~~~~~~~~~
src/main/include/log4cxx/config/propertysetter.h:30:1: note: in expansion of
macro ‘LOG4CXX_INSTANTIATE_EXPORTED_PTR’
30 | LOG4CXX_INSTANTIATE_EXPORTED_PTR(Object);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:468:
src/main/cpp/CMakeFiles/log4cxx.dir/domconfigurator.cpp.o] Error 1
gmake[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:272:
src/main/cpp/CMakeFiles/log4cxx.dir/class.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:226:
src/main/cpp/CMakeFiles/log4cxx.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]