The following code snippets show how to use Log4cxx with various different buildsystems.
Note that we are unable to provide support for all buildsystems that you may be using.
CMake is fully supported for building, as well as any buildsystem that can use pkgconfig in order to find packages. When using pkgconfig, the package name is liblog4cxx.
Add the following to your CMakeLists.txt file:
find_package(log4cxx) ... other buildsystem information here ... target_link_libraries( executable PRIVATE log4cxx )
Add the following to your CMakeLists.txt file:
find_package(PkgConfig)
pkg_check_modules(log4cxx REQUIRED liblog4cxx)
... other buildsystem information here ...
target_link_libraries( executable PRIVATE ${log4cxx_LIBRARIES} )
target_include_directories( executable PRIVATE ${log4cxx_INCLUDE_DIRS} )
Add the following to your .pro file:
CONFIG += link_pkgconfig PKGCONFIG += liblog4cxx
You probably don't want to do this - it is highly recommended to use a proper buildsystem. However, the following minimal Makefile will build and link an application:
CXXFLAGS += $(shell pkg-config --cflags liblog4cxx)
LDFLAGS += $(shell pkg-config --libs liblog4cxx)
all: main.o
$(CXX) -o application main.o $(LDFLAGS)