You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# curl -L -O https://dlcdn.apache.org/logging/log4cxx/1.2.0/apache-log4cxx-1.2.0.tar.gz
# tar xzvf apache-log4cxx-1.2.0.tar.gz
# apt-get install build-essential libapr1-dev libaprutil1-dev gzip zip
# cd apache-log4cxx-1.2.0
# mkdir build
# cd build
# cmake -DAPR_STATIC=yes ..
# make VERBOSE=1
cmake output:
-- The CXX compiler identification is GNU 11.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found APR: /usr/lib/x86_64-linux-gnu/libapr-1.a
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'apr-util-1'
-- Found apr-util-1, version 1.6.1
-- Found APR-Util: /usr/lib/x86_64-linux-gnu/libaprutil-1.so;/usr/lib/x86_64-linux-gnu/libldap.so;/usr/lib/x86_64-linux-gnu/liblber.so
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.4.7")
-- Looking for C++ include locale
-- Looking for C++ include locale - found
-- Looking for mbsrtowcs
-- Looking for mbsrtowcs - found
-- Looking for wcstombs
-- Looking for wcstombs - found
-- Looking for fwide
-- Looking for fwide - found
-- Looking for syslog
-- Looking for syslog - found
-- Looking for pthread_sigmask
-- Looking for pthread_sigmask - found
-- Looking for pthread_self
-- Looking for pthread_self - found
-- log4cxx configuration summary:
-- C++ compiler .................... : /usr/bin/c++
-- C++ features requested: ......... : 20
-- Build shared library ............ : ON
-- Build tests ..................... : ON
-- Build examples................... : ON
-- Build site ...................... : OFF
-- Install prefix .................. : /usr/local
-- log4cxx library name ............ : log4cxx
-- log4cxx namespace ............... : log4cxx
-- log4cxx char API ................ : ON
-- log4cxx wchar API ............... : ON
-- log4cxx unichar API ............. : OFF
-- log4cxx char type ............... : utf-8
-- character encoding .............. : utf-8
-- Networking support .............. : ON
-- DOMConfigurator support ......... : ON
-- Qt support ...................... : OFF
-- C++ version and Boost settings:
-- Prefer boost: ................... : OFF
-- make_unique implementation :..... : std::make_unique
-- filesystem implementation ....... : std::filesystem
-- format implementation ........... : fmt::format
-- thread_local support? ........... : TRUE
-- Applications required for tests:
-- zip ............................. : /usr/bin/zip
-- sed ............................. : /usr/bin/sed
-- gzip ............................ : /usr/bin/gzip
-- Available appenders:
-- Async Appender .................. : ON
-- ODBC Appender ................... : OFF
-- DB Appender ..................... : ON
-- SMTP Appender ................... : OFF
-- XMLSocketAppender ............... : ON
-- SocketHubAppender ............... : ON
-- SyslogAppender .................. : ON
-- Using syslog.h .................. : ON
-- TelnetAppender .................. : ON
-- NTEventLogAppender .............. : OFF
-- OutputDebugStringAppender ....... : ON
-- ConsoleAppender ................. : ON
-- FileAppender .................... : ON
-- RollingFileAppender ............. : ON
-- MultiprocessRollingFileAppender . : OFF
-- Available layouts:
-- HTMLLayout ...................... : ON
-- JSONLayout ...................... : ON
-- PatternLayout ................... : ON
-- SimpleLayout .................... : ON
-- XMLLayout ....................... : ON
-- FMTLayout ....................... : OFF
-- Configuring done
-- Generating done
The distro provided apr and apr-util static libraries are built without -fPIC (probably assuming everthing will be statically linked if anything is statically linked).
To build a log4cxx DSO with -DAPR_STATIC=yes you will need to also provide -DCMAKE_PREFIX_PATH=$HOME/libraries after populating $HOME/libraries with apr that you built yourself.
For example:
curl -L -O https://archive.apache.org/dist/apr/apr-1.7.4.tar.bz2
tar xf apr-1.7.4.tar.bz2
cd apr-1.7.4
export CFLAGS=-fPIC
./configure --prefix=$HOME/libraries
make install
I recommend you also use -DAPU_STATIC=yes when using -DAPR_STATIC=yes. This requires you build apr-util yourself as well.
curl -L -O https://archive.apache.org/dist/apr/apr-util-1.6.3.bz2
tar xf apr-util-1.6.3.bz2
cd apr-util-1.6.3
export CFLAGS=-fPIC
./configure --prefix=~/libraries --with-apr=$HOME/libraries
make install
Steps to reproduce:
cmake output:
-- The CXX compiler identification is GNU 11.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found APR: /usr/lib/x86_64-linux-gnu/libapr-1.a
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'apr-util-1'
-- Found apr-util-1, version 1.6.1
-- Found APR-Util: /usr/lib/x86_64-linux-gnu/libaprutil-1.so;/usr/lib/x86_64-linux-gnu/libldap.so;/usr/lib/x86_64-linux-gnu/liblber.so
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.4.7")
-- Looking for C++ include locale
-- Looking for C++ include locale - found
-- Looking for mbsrtowcs
-- Looking for mbsrtowcs - found
-- Looking for wcstombs
-- Looking for wcstombs - found
-- Looking for fwide
-- Looking for fwide - found
-- Looking for syslog
-- Looking for syslog - found
-- Looking for pthread_sigmask
-- Looking for pthread_sigmask - found
-- Looking for pthread_self
-- Looking for pthread_self - found
-- log4cxx configuration summary:
-- C++ compiler .................... : /usr/bin/c++
-- C++ features requested: ......... : 20
-- Build shared library ............ : ON
-- Build tests ..................... : ON
-- Build examples................... : ON
-- Build site ...................... : OFF
-- Install prefix .................. : /usr/local
-- log4cxx library name ............ : log4cxx
-- log4cxx namespace ............... : log4cxx
-- log4cxx char API ................ : ON
-- log4cxx wchar API ............... : ON
-- log4cxx unichar API ............. : OFF
-- log4cxx char type ............... : utf-8
-- character encoding .............. : utf-8
-- Networking support .............. : ON
-- DOMConfigurator support ......... : ON
-- Qt support ...................... : OFF
-- C++ version and Boost settings:
-- Prefer boost: ................... : OFF
-- make_unique implementation :..... : std::make_unique
-- filesystem implementation ....... : std::filesystem
-- format implementation ........... : fmt::format
-- thread_local support? ........... : TRUE
-- Applications required for tests:
-- zip ............................. : /usr/bin/zip
-- sed ............................. : /usr/bin/sed
-- gzip ............................ : /usr/bin/gzip
-- Available appenders:
-- Async Appender .................. : ON
-- ODBC Appender ................... : OFF
-- DB Appender ..................... : ON
-- SMTP Appender ................... : OFF
-- XMLSocketAppender ............... : ON
-- SocketHubAppender ............... : ON
-- SyslogAppender .................. : ON
-- Using syslog.h .................. : ON
-- TelnetAppender .................. : ON
-- NTEventLogAppender .............. : OFF
-- OutputDebugStringAppender ....... : ON
-- ConsoleAppender ................. : ON
-- FileAppender .................... : ON
-- RollingFileAppender ............. : ON
-- MultiprocessRollingFileAppender . : OFF
-- Available layouts:
-- HTMLLayout ...................... : ON
-- JSONLayout ...................... : ON
-- PatternLayout ................... : ON
-- SimpleLayout .................... : ON
-- XMLLayout ....................... : ON
-- FMTLayout ....................... : OFF
-- Configuring done
-- Generating done
make output:
...
[ 46%] Linking CXX shared library liblog4cxx.so
cd /home/clobo/log4cxx/apache-log4cxx-1.2.0/build/src/main/cpp && /usr/bin/cmake -E cmake_link_script CMakeFiles/log4cxx.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC -shared -Wl,-soname,liblog4cxx.so.15 -o liblog4cxx.so.15.2.0 CMakeFiles/log4cxx.dir/action.cpp.o CMakeFiles/log4cxx.dir/andfilter.cpp.o CMakeFiles/log4cxx.dir/appenderattachableimpl.cpp.o CMakeFiles/log4cxx.dir/appenderskeleton.cpp.o CMakeFiles/log4cxx.dir/aprinitializer.cpp.o CMakeFiles/log4cxx.dir/asyncappender.cpp.o CMakeFiles/log4cxx.dir/basicconfigurator.cpp.o CMakeFiles/log4cxx.dir/bufferedwriter.cpp.o CMakeFiles/log4cxx.dir/bytearrayinputstream.cpp.o CMakeFiles/log4cxx.dir/bytearrayoutputstream.cpp.o CMakeFiles/log4cxx.dir/bytebuffer.cpp.o CMakeFiles/log4cxx.dir/cacheddateformat.cpp.o CMakeFiles/log4cxx.dir/charsetdecoder.cpp.o CMakeFiles/log4cxx.dir/charsetencoder.cpp.o CMakeFiles/log4cxx.dir/class.cpp.o CMakeFiles/log4cxx.dir/classnamepatternconverter.cpp.o CMakeFiles/log4cxx.dir/classregistration.cpp.o CMakeFiles/log4cxx.dir/colorstartpatternconverter.cpp.o CMakeFiles/log4cxx.dir/colorendpatternconverter.cpp.o CMakeFiles/log4cxx.dir/configurator.cpp.o CMakeFiles/log4cxx.dir/consoleappender.cpp.o CMakeFiles/log4cxx.dir/cyclicbuffer.cpp.o CMakeFiles/log4cxx.dir/date.cpp.o CMakeFiles/log4cxx.dir/dateformat.cpp.o CMakeFiles/log4cxx.dir/datepatternconverter.cpp.o CMakeFiles/log4cxx.dir/dbappender.cpp.o CMakeFiles/log4cxx.dir/defaultconfigurator.cpp.o CMakeFiles/log4cxx.dir/defaultloggerfactory.cpp.o CMakeFiles/log4cxx.dir/defaultrepositoryselector.cpp.o CMakeFiles/log4cxx.dir/exception.cpp.o CMakeFiles/log4cxx.dir/fallbackerrorhandler.cpp.o CMakeFiles/log4cxx.dir/file.cpp.o CMakeFiles/log4cxx.dir/fileappender.cpp.o CMakeFiles/log4cxx.dir/filedatepatternconverter.cpp.o CMakeFiles/log4cxx.dir/fileinputstream.cpp.o CMakeFiles/log4cxx.dir/filelocationpatternconverter.cpp.o CMakeFiles/log4cxx.dir/fileoutputstream.cpp.o CMakeFiles/log4cxx.dir/filerenameaction.cpp.o CMakeFiles/log4cxx.dir/filewatchdog.cpp.o CMakeFiles/log4cxx.dir/filter.cpp.o CMakeFiles/log4cxx.dir/filterbasedtriggeringpolicy.cpp.o CMakeFiles/log4cxx.dir/fixedwindowrollingpolicy.cpp.o CMakeFiles/log4cxx.dir/formattinginfo.cpp.o CMakeFiles/log4cxx.dir/fulllocationpatternconverter.cpp.o CMakeFiles/log4cxx.dir/gzcompressaction.cpp.o CMakeFiles/log4cxx.dir/hexdump.cpp.o CMakeFiles/log4cxx.dir/hierarchy.cpp.o CMakeFiles/log4cxx.dir/htmllayout.cpp.o CMakeFiles/log4cxx.dir/inetaddress.cpp.o CMakeFiles/log4cxx.dir/inputstream.cpp.o CMakeFiles/log4cxx.dir/inputstreamreader.cpp.o CMakeFiles/log4cxx.dir/integer.cpp.o CMakeFiles/log4cxx.dir/integerpatternconverter.cpp.o CMakeFiles/log4cxx.dir/jsonlayout.cpp.o CMakeFiles/log4cxx.dir/layout.cpp.o CMakeFiles/log4cxx.dir/level.cpp.o CMakeFiles/log4cxx.dir/levelmatchfilter.cpp.o CMakeFiles/log4cxx.dir/levelpatternconverter.cpp.o CMakeFiles/log4cxx.dir/levelrangefilter.cpp.o CMakeFiles/log4cxx.dir/linelocationpatternconverter.cpp.o CMakeFiles/log4cxx.dir/lineseparatorpatternconverter.cpp.o CMakeFiles/log4cxx.dir/literalpatternconverter.cpp.o CMakeFiles/log4cxx.dir/loader.cpp.o CMakeFiles/log4cxx.dir/locale.cpp.o CMakeFiles/log4cxx.dir/locationinfo.cpp.o CMakeFiles/log4cxx.dir/locationinfofilter.cpp.o CMakeFiles/log4cxx.dir/logger.cpp.o CMakeFiles/log4cxx.dir/loggermatchfilter.cpp.o CMakeFiles/log4cxx.dir/loggerpatternconverter.cpp.o CMakeFiles/log4cxx.dir/loggingevent.cpp.o CMakeFiles/log4cxx.dir/loggingeventpatternconverter.cpp.o CMakeFiles/log4cxx.dir/loglog.cpp.o CMakeFiles/log4cxx.dir/logmanager.cpp.o CMakeFiles/log4cxx.dir/logstream.cpp.o CMakeFiles/log4cxx.dir/manualtriggeringpolicy.cpp.o CMakeFiles/log4cxx.dir/mapfilter.cpp.o CMakeFiles/log4cxx.dir/mdc.cpp.o CMakeFiles/log4cxx.dir/messagebuffer.cpp.o CMakeFiles/log4cxx.dir/messagepatternconverter.cpp.o CMakeFiles/log4cxx.dir/methodlocationpatternconverter.cpp.o CMakeFiles/log4cxx.dir/nameabbreviator.cpp.o CMakeFiles/log4cxx.dir/namepatternconverter.cpp.o CMakeFiles/log4cxx.dir/ndc.cpp.o CMakeFiles/log4cxx.dir/mdcpatternconverter.cpp.o CMakeFiles/log4cxx.dir/ndcpatternconverter.cpp.o CMakeFiles/log4cxx.dir/nteventlogappender.cpp.o CMakeFiles/log4cxx.dir/odbcappender.cpp.o CMakeFiles/log4cxx.dir/onlyonceerrorhandler.cpp.o CMakeFiles/log4cxx.dir/optionconverter.cpp.o CMakeFiles/log4cxx.dir/outputdebugstringappender.cpp.o CMakeFiles/log4cxx.dir/outputstream.cpp.o CMakeFiles/log4cxx.dir/outputstreamwriter.cpp.o CMakeFiles/log4cxx.dir/patternconverter.cpp.o CMakeFiles/log4cxx.dir/patternlayout.cpp.o CMakeFiles/log4cxx.dir/patternparser.cpp.o CMakeFiles/log4cxx.dir/pool.cpp.o CMakeFiles/log4cxx.dir/properties.cpp.o CMakeFiles/log4cxx.dir/propertiespatternconverter.cpp.o CMakeFiles/log4cxx.dir/propertyconfigurator.cpp.o CMakeFiles/log4cxx.dir/propertyresourcebundle.cpp.o CMakeFiles/log4cxx.dir/propertysetter.cpp.o CMakeFiles/log4cxx.dir/reader.cpp.o CMakeFiles/log4cxx.dir/relativetimedateformat.cpp.o CMakeFiles/log4cxx.dir/relativetimepatternconverter.cpp.o CMakeFiles/log4cxx.dir/resourcebundle.cpp.o CMakeFiles/log4cxx.dir/rollingfileappender.cpp.o CMakeFiles/log4cxx.dir/rollingpolicy.cpp.o CMakeFiles/log4cxx.dir/rollingpolicybase.cpp.o CMakeFiles/log4cxx.dir/rolloverdescription.cpp.o CMakeFiles/log4cxx.dir/rootlogger.cpp.o CMakeFiles/log4cxx.dir/shortfilelocationpatternconverter.cpp.o CMakeFiles/log4cxx.dir/simpledateformat.cpp.o CMakeFiles/log4cxx.dir/simplelayout.cpp.o CMakeFiles/log4cxx.dir/sizebasedtriggeringpolicy.cpp.o CMakeFiles/log4cxx.dir/smtpappender.cpp.o CMakeFiles/log4cxx.dir/strftimedateformat.cpp.o CMakeFiles/log4cxx.dir/stringhelper.cpp.o CMakeFiles/log4cxx.dir/stringmatchfilter.cpp.o CMakeFiles/log4cxx.dir/stringtokenizer.cpp.o CMakeFiles/log4cxx.dir/system.cpp.o CMakeFiles/log4cxx.dir/systemerrwriter.cpp.o CMakeFiles/log4cxx.dir/systemoutwriter.cpp.o CMakeFiles/log4cxx.dir/threadlocal.cpp.o CMakeFiles/log4cxx.dir/threadpatternconverter.cpp.o CMakeFiles/log4cxx.dir/threadusernamepatternconverter.cpp.o CMakeFiles/log4cxx.dir/threadspecificdata.cpp.o CMakeFiles/log4cxx.dir/threadutility.cpp.o CMakeFiles/log4cxx.dir/throwableinformationpatternconverter.cpp.o CMakeFiles/log4cxx.dir/timebasedrollingpolicy.cpp.o CMakeFiles/log4cxx.dir/timezone.cpp.o CMakeFiles/log4cxx.dir/transcoder.cpp.o CMakeFiles/log4cxx.dir/transform.cpp.o CMakeFiles/log4cxx.dir/triggeringpolicy.cpp.o CMakeFiles/log4cxx.dir/writer.cpp.o CMakeFiles/log4cxx.dir/writerappender.cpp.o CMakeFiles/log4cxx.dir/xmllayout.cpp.o CMakeFiles/log4cxx.dir/zipcompressaction.cpp.o CMakeFiles/log4cxx.dir/datagrampacket.cpp.o CMakeFiles/log4cxx.dir/datagramsocket.cpp.o CMakeFiles/log4cxx.dir/aprdatagramsocket.cpp.o CMakeFiles/log4cxx.dir/serversocket.cpp.o CMakeFiles/log4cxx.dir/aprserversocket.cpp.o CMakeFiles/log4cxx.dir/socket.cpp.o CMakeFiles/log4cxx.dir/aprsocket.cpp.o CMakeFiles/log4cxx.dir/telnetappender.cpp.o CMakeFiles/log4cxx.dir/socketappenderskeleton.cpp.o CMakeFiles/log4cxx.dir/socketoutputstream.cpp.o CMakeFiles/log4cxx.dir/xmlsocketappender.cpp.o CMakeFiles/log4cxx.dir/syslogwriter.cpp.o CMakeFiles/log4cxx.dir/syslogappender.cpp.o CMakeFiles/log4cxx.dir/domconfigurator.cpp.o /usr/lib/x86_64-linux-gnu/libaprutil-1.so /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/x86_64-linux-gnu/libexpat.so /usr/lib/x86_64-linux-gnu/libapr-1.a -lpthread
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libapr-1.a(open.o): warning: relocation against
apr_unix_child_file_cleanup' in read-only section
.text'/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libapr-1.a(proc_mutex.o): relocation R_X86_64_PC32 against symbol `apr_proc_mutex_cleanup' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/main/cpp/CMakeFiles/log4cxx.dir/build.make:2502: src/main/cpp/liblog4cxx.so.15.2.0] Error 1
make[2]: Leaving directory '/home/clobo/log4cxx/apache-log4cxx-1.2.0/build'
make[1]: *** [CMakeFiles/Makefile2:1366: src/main/cpp/CMakeFiles/log4cxx.dir/all] Error 2
make[1]: Leaving directory '/home/clobo/log4cxx/apache-log4cxx-1.2.0/build'
make: *** [Makefile:146: all] Error 2
The text was updated successfully, but these errors were encountered: