Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error building log4cxx with cmake, APR_STATIC and APU_STATIC options #366

Open
clobotorre opened this issue Apr 8, 2024 · 2 comments
Open

Comments

@clobotorre
Copy link

Based on the answer to this issue #362 I have done following steps on both Ubuntu 18.04 and Ubuntu 22.04.

Initial steps

	# mkdir /home/test_build_log4cxx_with_static_apr_libs
	# mkdir /home/test_build_log4cxx_with_static_apr_libs/target

libapr compilation steps

	# cd /home/test_build_log4cxx_with_static_apr_libs
	# mkdir apr
	# cd apr
	# 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
	# touch libtoolT
	# export CFLAGS=-fPIC
	# ./configure --prefix=/home/test_build_log4cxx_with_static_apr_libs/target
	# make install

libapr-util compilation steps

	# cd /home/test_build_log4cxx_with_static_apr_libs/apr
	# curl -L -O https://archive.apache.org/dist/apr/apr-util-1.6.3.tar.bz2
	# tar xf apr-util-1.6.3.tar.bz2
	# cd apr-util-1.6.3
	# export CFLAGS=-fPIC
	# ./configure --prefix=/home/test_build_log4cxx_with_static_apr_libs/target --with-apr=/home/test_build_log4cxx_with_static_apr_libs/target
	# make install	

log4cxx compilation steps

	# cd /home/test_build_log4cxx_with_static_apr_libs
	# mkdir log4cxx
	# cd log4cxx
	# 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
	# cd apache-log4cxx-1.2.0
	# mkdir build
	# cd build
	# cmake -DAPR_STATIC=yes -DAPU_STATIC=yes -DCMAKE_PREFIX_PATH=/home/test_build_log4cxx_with_static_apr_libs/target/ ..
	# make
	# make install					

I have no problems on Ububntu 22.04, but on Ubuntu 18.04, the make command output ends like this:

[ 54%] Building CXX object src/test/cpp/CMakeFiles/autoconfiguretestcase.dir/autoconfiguretestcase.cpp.o
[ 54%] Linking CXX executable autoconfiguretestcase
../../main/cpp/liblog4cxx.so.15.2.0: undefined reference to `dlclose'
../../main/cpp/liblog4cxx.so.15.2.0: undefined reference to `dlsym'
../../main/cpp/liblog4cxx.so.15.2.0: undefined reference to `dlopen'
../../main/cpp/liblog4cxx.so.15.2.0: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
src/test/cpp/CMakeFiles/autoconfiguretestcase.dir/build.make:100: recipe for target 'src/test/cpp/autoconfiguretestcase' failed
make[2]: *** [src/test/cpp/autoconfiguretestcase] Error 1
CMakeFiles/Makefile2:1419: recipe for target 'src/test/cpp/CMakeFiles/autoconfiguretestcase.dir/all' failed
make[1]: *** [src/test/cpp/CMakeFiles/autoconfiguretestcase.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2
@rm5248
Copy link
Contributor

rm5248 commented Apr 8, 2024

If it's only the tests, you can just disable the tests(add -DBUILD_TESTING=OFF when configuring with cmake). Or, add -ldl to your linker flags.

Is there a particular reason it needs to be statically linked? Dynamically linking is the normal way to use log4cxx.

@clobotorre
Copy link
Author

Thank you. I'll use -DBUILD_TESTING=OFF

I need APR libs statically linked because in the target machines there are already another (needed) version of APR libs wich conflicts with the ones needed by log4cxx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants