Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8290069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:41:17+00:00 2026-06-08T12:41:17+00:00

I am considering using log4cplus in a project built with the GNU Autotools .

  • 0

I am considering using log4cplus in a project built with the GNU Autotools. For other library dependencies (such as boost) I’ve been able to find reasonable canonical M4 macros to test for those dependencies.

After a bit of looking I’m still unable to find a similar stock macro for lib4cplus. I’m aware I could likely craft my own, but “standard” versions are preferable where possible. Does anyone know of any?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:41:18+00:00Added an answer on June 8, 2026 at 12:41 pm

    Here’s what I’m running with, given the apparent absence of pkg-config support in 1.0.4.

    I strongly suggest future users to first check the source repo, since a macro provided there may see community support, while this version will not.

    # log4cplus.m4: Autoconf macro to test for the presence and version of lib4cplus.
    #
    # SYNOPSIS
    #
    #   LOG4CPLUS([MINIMUM-VERSION = 1.0.4])
    #
    # DESCRIPTION
    #
    #   Test for the presence and version of the log4cplus logging library.  Specifically, the
    #   log4cplus/logger.h header must be present, and a test program must link.  The version check is
    #   preprocessor comparison against LOG4CPLUS_VERSION in version.h.
    #
    #   If present, LOG4CPLUS_CPPFLAGS, LOG4CPLUS_LDFLAGS and LOG4CPLUS_LIBS affect preprocessor and
    #   linker behavior.  If absent LOG4CPLUS_LIBS defaults to -llog4cplus.
    #
    #   If a suitable library is found, HAVE_LOG4CPLUS is defined.
    #
    # EXAMPLE
    #
    #     LOG4CPLUS([1.1.0])
    #
    AC_DEFUN([LOG4CPLUS], [
      # We need sed to turn 1.0.4 into 1, 0, 4 below
      AC_REQUIRE([AC_PROG_SED])
    
      # Declare the LOG4CPLUS_* variables as "precious"
      AC_ARG_VAR([LOG4CPLUS_CPPFLAGS], [preprocessor flags for log4cplus headers])
      AC_ARG_VAR([LOG4CPLUS_LDFLAGS], [linker flags for log4cplus])
      AC_ARG_VAR([LOG4CPLUS_LIBS], [libraries log4cplus])
    
      # Supply a default LOG4CPLUS_LIBS if needed
      AS_IF(
        [test "x$LOG4CPLUS_LIBS" = "x"],
        [LOG4CPLUS_LIBS=-llog4cplus])
    
      # In a cache block..
      AC_CACHE_VAL([log4cplus_cv_lib_log4cplus], [
        # Back up CPPFLAGS, LDFLAGS & LIBS, declare we'll be testing in C++
        save_CPPFLAGS="$CPPFLAGS"
        save_LDFLAGS="$LDFLAGS"
        save_LIBS="$LIBS"
        AC_LANG_PUSH([C++])
    
        # Append LOG4CPLUS_CPPFLAGS to CPPFLAGS if present
        AS_IF(
          [test "x$LOG4CPLUS_CPPFLAGS" != "x"],
          [CPPFLAGS="$CPPFLAGS $LOG4CPLUS_CPPFLAGS"])
    
        # Append LOG4CPLUS_LDFLAGS to LDFLAGS if present
        AS_IF(
          [test "x$LOG4CPLUS_LDFLAGS" != "x"],
          [LDFLAGS="$LDFLAGS $LOG4CPLUS_LDFLAGS"])
    
        # Append LOG4CPLUS_LIBS to LIBS if present
        AS_IF(
          [test "x$LOG4CPLUS_LIBS" != "x"],
          [LIBS="$LIBS $LOG4CPLUS_LIBS"])
    
        # If a minimum required version was specified, capture it in a variable.
        # If not, assume 1.0.4
        AS_IF([test "x$1" = "x"],
          [min_version=1.0.4],
          [min_version=$1])
    
        # Format the minimum version in a way suitable for the LOG4CPLUS_MAKE_VERSION macro
        min_version_commas=`echo $min_version | $SED -e 's/\./, /g'`
    
        # Now the checks.  Note that we try to avoid side-effects in this block, instead setting only
        # the cache variable.  Mutations come after.  First, can we find a header?
        AC_CHECK_HEADER([log4cplus/logger.h],
          # Can we link against the library?
          [AC_MSG_CHECKING([if log4cplus links])]
          [AC_LINK_IFELSE(
            [AC_LANG_PROGRAM(
              [[#include <log4cplus/logger.h>]],
              [[log4cplus::Logger logger]])],
            [AC_MSG_RESULT([yes])]
            # Is the present version new enough?
            [AC_MSG_CHECKING([if log4cplus is version compatible])]
            [AC_COMPILE_IFELSE(
              [AC_LANG_PROGRAM(
                [[#include <log4cplus/version.h>]], [[
                #if LOG4CPLUS_MAKE_VERSION(]$min_version_commas[) <= LOG4CPLUS_VERSION
                #else
                  error: version check failed.
                #endif
                ]])],
              [AC_MSG_RESULT([yes])]
              [log4cplus_cv_lib_log4cplus=yes],
              [AC_MSG_RESULT([no])]
              [log4cplus_cv_lib_log4cplus=no])],
            [AC_MSG_RESULT([no])]
            [log4cplus_cv_lib_log4cplus=no])],
          [log4cplus_cv_lib_log4cplus=no])
    
        AC_LANG_POP([C++])
        CPPFLAGS="$save_CPPFLAGS"
        LDFLAGS="$save_LDFLAGS"
        LIBS="$save_LIBS"
      ])
    
      # Define HAVE_LOG4CPLUS if the check passed.
      AS_IF([test "x$log4cplus_cv_lib_log4cplus" = "xyes"],
        [AC_DEFINE([HAVE_LOG4CPLUS], [1], [Define to 1 if log4cplus is found])])
    ])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm considering using Grails for my current project. I have a couple of requirements
I'm considering using the VB6 Common Controls Replacement Project controls and would like to
I'm considering using mysql's built-in aes_encrypt . I normally use blowfish, but mysql doesn't
Am considering using it for a project. It keeps getting recommended to me. I
I'm considering using Express framework in my next node.js project. However, a stumbling block
I am considering using Fluent NHibernate for my project and I haven't found any
I am considering using Maven for a Java open source project I manage. In
I'm considering using boost::ptr_container as a result of the responses from this question .
I'm considering using the Word Automation Services feature of SharePoint 2010 for a project.
I was recently considering using GoogleData for a hobby project to store my service's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.