Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to add a directory to linker command line in linux

Writer Olivia Zamora

I am new to Linux and I want to add lib64/librt.so.1 to the linker command line. Can anyone suggest how to do this? Thanks in advance

1 Answer

  1. If you are compiling something and you want the compiler to search a specific directory, you can add the -L flag. Like this:

    g++ -L /lib64
  2. You can also add this directory to the environment variable 'LD_LIBRARY_PATH'. Like this:

    export LD_LIBRARY_PATH="/lib64"
  3. You can also use ldconfig to add a directory to the search path. Like this:

    sudo ldconfig /lib64
  4. Finally, you can add the directory to /etc/ld.so.conf.d/mylibs.conf (and rerun sudo ldconfig) to make this change permanent.

    echo "/lib64" | sudo tee -a /etc/ld.so.conf.d/mylibs.conf; sudo ldconfig
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy