I am building and running C++ project in WSL Ubuntu 20.04 through Visual Studio 2022 on Windows 10.
I included all relevant paths to project's Additional Library Search Path and all .so files to Library Dependecies and was able to build the project in VS.
However, when I run in VS I get error while loading shared libraries: xxx.so: cannot open shared object file: No such file or directory. The missing .so is located at /home/myuser/my_ws/install/lib (DIR). If I copy manually that library from DIR to /usr/lib/x86_64-linux-gnu then it can find it.
I tried adding that .so to Configuration Properties -> Debugging -> Additional Symbol Search Paths, but it didn't help

UPDATE
I tried adding export LD_LIBRARY_PATH=/home/myuser/my_ws/install/lib to Pre-Launch Command as suggested by @Sam Varshavchik and it worked.

To load a .so library at runtime, one of the following three conditions must be met.
The .so library must be located in one of the default system library locations, like /usr/lib or /usr/lib64, or various subdirectories there. Additional default system library locations are listed in /etc/ld.so.conf.
The LD_LIBRARY_PATH environment variable must be set, accordingly, before running the executable that attempts to load the .so file.
The executable must be linked with the -rpath or -R linker flag, specifying the directory to add to the search path, at runtime.
You can decide which approach will work the best for you, and proceed accordingly. See the ld.so(8) manual page for a complete description of the shared library loading process, and additional options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With