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

  • Home
  • SEARCH
  • 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 6828093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:20:34+00:00 2026-05-26T22:20:34+00:00

I have the following code which is failing to compile. #include <stdio.h> #include <log4cpp/Category.hh>

  • 0

I have the following code which is failing to compile.

#include <stdio.h>
#include <log4cpp/Category.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/SimpleLayout.hh>

#define LOGFILE "./test.log"

int main()
{
    /*Setting up Appender, layout and Category*/
    log4cpp::Appender *appender = new log4cpp::FileAppender("FileAppender",LOGFILE);
    log4cpp::Layout *layout = new log4cpp::SimpleLayout();
    log4cpp::Category& category = log4cpp::Category::getInstance("Category");

    appender->setLayout(layout);
    category.setAppender(appender);
    category.setPriority(log4cpp::Priority::INFO);

    /*The actual logging*/
    category.info("This is for tracing the flow");
    category.notice("This is to notify certain events");
    category.warn("This is to generate certain warnings");
}

$ g++ -I/usr/local/include/log4cpp -L/usr/local/lib/ -llog4cpp -lpthread log.cc

This compiles. But then i get the following error.

./a.out: error while loading shared libraries: liblog4cpp.so.4: cannot open shared object file: No such file or directory

I do see liblog4cpp.so.4 in /usr/local/lib folder.
How can i resolve this?

  • 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-05-26T22:20:35+00:00Added an answer on May 26, 2026 at 10:20 pm

    If you are linking from a non-standard location, the loader won’t find the library. You have several options:

    1. Inform it on a case-by-case basis: LD_LIBRARY_PATH=/usr/local/lib ./aout

    2. Hard-code the path into the executable: Add -Wl,-r,/usr/local/lib to the linker command.

    3. Fiddle with the environment (I think you just export LD_LIBRARY_PATH).

    (A proper build environment (such as cmake) will typically add the linker option from (2) automatically if you make it locate your libraries in non-standard location.)

    Always check ldd ./a.out if you have loading problems to check which libraries are missing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query in ASP.NET/C# code which is failing to return any
I have the following code in a JUnit test, which seemed to work last
I have a relatively simple use case which is failing. Consider the following code:
I'm trying to use opengl in C#. I have following code which fails with
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code which works just fine when the method is POST,
I have the following code which works fine. However, I only want to return
I have the following code which should put programs startable in Bash. if [
I have the following code which reads in the follow file, append a \r\n
I have the following code which re-uses a CookieContainer which logs in on the

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.