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 8452199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:26:25+00:00 2026-06-10T11:26:25+00:00

I have a written a small c++ project on a linux box. I am

  • 0

I have a written a small c++ project on a linux box. I am able to compile and link the code properly with the -I and _L,-l commands.

I read on the net that while running the code, we need to have the path to the .so files in the LD_LIBRARY_PATH variable. Now the box that I am using is 64 bit and there is another application that uses 32 bit version of the library. So the LD_LIBRARY_PATH has paths to both versions of the library.

When I try to run my application eg. ./xyz arg1 arg2, I get the following error

./DaemonCpp: error while loading shared libraries: libldap.so: wrong ELF class: ELFCLASS32

I think this is because it is trying to load 32 bit version instead of 64 bit version. I tried changing the order in which the paths are mentioned in LD_LIBRARY_PATH such that the path to 64 bit comes first but still I get this error. Is there a way I could direct the app to use the 64 bit version of the library.

As a secondary question to my primary problem, when we are linking the c++ code, we do specify the library path using the -L and library name using -l. Then it should have known which library to use when I run the executable and I shouldn’t have got this error in the first place

  • 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-10T11:26:26+00:00Added an answer on June 10, 2026 at 11:26 am

    In answer to your second question, you only used -L to specify the link time path. You need to also add -rpath=<path> for each path that you specify with -L. to get it to look at run-time as well.

    If you’re using the gcc/g++ driver for linking, then you should use -Wl,-rpath=<path>

    e.g. library libfoo.so in /opt/libs/lib64:

    gcc -o test test.o -L/opt/libs/lib64 -Wl,-rpath=/opt/libs/lib64 -lfoo
    

    In answer to your first question, if LD_LIBRARY_PATH is causing issues, then your first port of call is ldd which shows the paths to the libraries that are being linked at run-time. Start with an empty string and work up from there.

    Thirdly, if the reason that LD_LIBRARY_PATH needs to be set is because there are libraries in /opt/lib, etc… then you should be adding these paths to your /etc/ld.so.conf and using ldconfig to update the search map for these libraries. This will typically save you from needing the LD_LIBRARY_PATH variable at all.

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

Sidebar

Related Questions

I've got a relatively small ASP.NET project that was written using C# 4.0. I
I have written a small Android project that shows some (image)buttons. It works fine
I have a small project that is written in Groovy and deployed as a
I have written a small chat app that uses mysql + php to facilitate
I have written a small app that puts my bluetooth in discoverable mode for
I have written a small .net Windows Forms application. And now I decided to
I have written a small makefile for a few simple C programs that compiles
What I have written a small piece of code to find and remove if
I have written a very small C# program, that uses a very small SQL
I have a small desktop Twitter client written in VB.NET (2.0). Works great. Some

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.