
Jacob C. answered 08/09/20
Master's in Computer Science with 6+ Years Career Experience
What's going on here is that the linker ld cannot find the shared object file that you're trying to link against. By default, ld is going to search select system directories for your libraries. I suspect there's one of two things going on here. Either you don't have the library installed on your system, or you have it downloaded and/or installed into a non-traditional location.
In the case of the first (library isn't installed), you'll just need to install it. Use your package manager (apt for Ubuntu, for example) to search for the library and try to install the development package for it as well.
In the case of the second, where you know the library is installed, you just need to find it. Once you have the path to the .so file, add a -L flag to your g++ command and give it the path to the directory containing your .so file. The -L flag tells g++ to have the linker search the additional location for shared object files.
For example, if your .so file is under /home/user/libs/libcustom.so, you could do something like this:
g++ -L/home/user/libs -lcustom ...
If you're interested in discussing this some more and getting one-on-one help, hit me up!
Charlie B.
not seeing my comment05/20/23
Charlie B.
I am having this same issue. I am using g++ -l:/usr/local/lib/libname.so.2.70 -v main.cpp message using -v option says ld cannot find the file ls /usr/local/lib/shows the lib is there. I am lost05/20/23