I've difficulty to make my snippet code working on centos 7.
So, I've these packages installed on the box:
log4cxx.x86_64, log4cxx-devel.x86_64, apr.x86_64, apr-devel.x86_64, apr-util.x86_64, apr-util-devel.x86_64, glib2.x86_64, glib2-devel.x86_64
in CMakeList.txt, I've tried bunch of combinations (successful build), but I ended up with same result when executing the binary.
Currently, I've this :
find_package(PkgConfig)
find_library(LOG4CXX_LIBRARY log4cxx)
Although I'm positive that it could find the library, but i also tried:
-llog4cxx -lapr-1 -laprutil-1 -lexpat -lglib-2.0
I built with both configs, and when i run the executable output, I'll get:
undefined symbol: _ZN7log4cxx3xml15DOMConfigurator9configureERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
The 'nm' output is:
$ nm -D /usr/lib64/liblog4cxx.so | grep _ZN7log4cxx3xml15DOMConfigurator9configure
00000000000f9ff0 T _ZN7log4cxx3xml15DOMConfigurator9configureERKSbIwSt11char_traitsIwESaIwEE
00000000000f9e40 T _ZN7log4cxx3xml15DOMConfigurator9configureERKSs
in my .cpp I've basically use this:
try {
log4cxx::xml::DOMConfigurator::configure("/root/1.xml");
}
catch (log4cxx::helpers::Exception&) {
fprintf( stderr, "Error on loading Log-config file" );
return -1;
}
ps: Same project compiles and run on FreeBSD 12 with no issue.