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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:55:00+00:00 2026-06-01T06:55:00+00:00

Im trying to link my program to the shared library. Im using a makefile

  • 0

Im trying to link my program to the shared library. Im using a makefile to compile. It looks like this: `

make: sms_out.cpp SMSDispatch.cpp SMSDispatch.h
      g++ -c -fPIC SMSDispatch.cpp -o SMSDispatch.o
      g++ -shared SMSDispatch.o -o libSMSDispatch.so
`     g++ sms_out.cpp -L. -lSMSDispatch -o sms_out

It works fine if I run the program in the command window with:

LD_LIBRARY_PATH="." ./sms_out

But I want to run it with just ./sms_out, can someone help me?
Tried to add export LD_LIBRARY_PATH=. to the makefile, but that didnt work, just got the error ” error while loading shared libraries: libSMSDispatch.so: cannot open shared object file: No such file or directory” when I try to run the program.

  • 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-01T06:55:01+00:00Added an answer on June 1, 2026 at 6:55 am

    Add the directory where the .so file exists to LD_LIBRARY_PATH:

    $ export LD_LIBRARY_PATH=/dir/containing/sharedobject
    

    A utility you may find useful is ldd, which prints the shared library dependencies. For example:

        $ ldd /bin/ls
            linux-vdso.so.1 =>  (0x00007fff819ff000)
            librt.so.1 => /lib64/librt.so.1 (0x00007fc0d3f67000)
            libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fc0d3d4a000)
            libacl.so.1 => /lib64/libacl.so.1 (0x00007fc0d3b42000)
            libc.so.6 => /lib64/libc.so.6 (0x00007fc0d37e9000)
            libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc0d35cd000)
            /lib64/ld-linux-x86-64.so.2 (0x00007fc0d4170000)
            libdl.so.2 => /lib64/libdl.so.2 (0x00007fc0d33c9000)
            libattr.so.1 => /lib64/libattr.so.1 (0x00007fc0d31c4000)
    

    If shared objects are not locatable a string not found, or similar, is displayed instead of the path to the shared object being used.

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

Sidebar

Related Questions

I am trying to link a C++ module using GCC, essentially like this: gcc
I'm trying to link 10 computers together, the program I would like to write
I'm using minGW on windows, trying to compile a c++ program. I've used sockets
I'm trying to link to a shared library with a template class, but it
I'm trying to create a shared library on ubuntu using gcc I just have
Using glew, I'm trying to link the simple program #include </usr/include/GL/glew.h> int main (int
I'm having a problem when trying to compile the program in this tutorial from
I'm using CodeBlocks and trying to link SDL_ttf when compiling my program. I have
I have a problem while trying to compile and link my program with dmalloc.
I'm trying to link my mac application to the wonderful libancillary library. However, I

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.