Software⏱️ 3 min read📅 2026-06-19

How to Fix: Error while loading shared libraries - libwebsock

Error while loading shared libraries - libwebsock: unable to find shared object file.

Quick Answer: Check the library's installation directory and ensure it is in the system's ld.so configuration path.

The error 'error while loading shared libraries: libwebsock.so.1: cannot open shared object file: No such file or directory' occurs when the system is unable to find the shared library 'libwebsock.so.1' at runtime, despite its existence in the /usr/local/lib directory.

This issue can be particularly frustrating for developers as they are able to compile and run test programs successfully, but encounter difficulties when trying to execute their own executable files.

🔍 Why This Happens

  • The primary reason for this error is that the system's ld.so (dynamic linker) is not configured to search for shared libraries in the /usr/local/lib directory. This can happen if the library path is not properly set or if the ld.so configuration file (/etc/ld.so.conf) contains incorrect or missing entries.
  • Another possible reason could be related to the system's permissions or ownership issues, where the user running the executable does not have the necessary privileges to access the shared library.

✅ Best Solutions to Fix It

Update ld.so configuration and set library path

  1. Step 1: Open the /etc/ld.so.conf file in a text editor and add the following line at the end: `# Add the /usr/local/lib directory to the system's library search path` `/usr/local/lib` `# Save and close the file`
  2. Step 2: Run the command `sudo ldconfig` to update the ld.so configuration and make sure the new library path is recognized by the dynamic linker. This step may take some time, so be patient.
  3. Step 3: Verify that the system can now find the shared library 'libwebsock.so.1' by running the command `ldd /usr/local/lib/libwebsock.so.1` (assuming libwebsock.so.1 exists in /usr/local/lib)

Change ownership and permissions of the executable file

  1. Step 1: Run the command `sudo chown -R user:group /path/to/executable` to change the ownership of the executable file to the current user. Replace '/path/to/executable' with the actual path to your executable.
  2. Step 2: Run the command `sudo chmod u+x /path/to/executable` to set the execute permission for the owner of the executable file.

🎯 Final Words

By following these steps, you should be able to resolve the 'error while loading shared libraries: libwebsock.so.1: cannot open shared object file: No such file or directory' issue and successfully run your executable file.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions