There's a lot to unpack here, so I'll go section-by-section:
NOTE: This is long enough that it's collapsed by default. Don't overlook the little (more) link at the end.
But what is DSO and what it has to do with the command line?
"DSO" is short for "Dynamic Shared Object" and it's platform-agnostic jargon for a .so
, .dylib
, or .dll
file, as fits the platform.
I've written almost no C++ (Python mainly), but I believe "error adding symbols: DSO missing from command line" means "Your code references this library, but you didn't ask me to link it in. I don't know which one was a mistake, so please either edit your code to not use it or add a -l
for it to your g++ ...
command and try again."
I would not ask about symbol '_ZN2cv6imreadERKNS_6StringEi' gobbledegook.
I should probably explain it anyway. ld
uses a symbol name lookup system that predates C++ and only work on strings for names, so, when multiple functions or methods have the same name, differing only in their arguments or what class they belong to, they need to be disambiguated.
I won't give a full guide to decoding _ZN2cv6imreadERKNS_6StringEi but I will point out the imread
in the middle of it. The gobbledegook is how ld
sees the version of imread
that your code is trying to call.
I installed openCV using .sh script downloaded from
A quick caution. It doesn't look like you ran make install
but, if you ever want to, I advise installing checkinstall
and running that instead. It'll give you a wizard for building a .deb
package from make install
and then install it for you, making it easy to uninstall with sudo apt remove PACKAGE_NAME
or track what got installed with dpkg -L PACKAGE_NAME
.
find / -name opencv_imgcodecs
-name
does exact string matching, so find / -name opencv_imgcodecs
(without any wildcards) should return no results.
If you've had time for your nightly updatedb
run to occur since installing your libraries, I'd suggest locate opencv_imgcodecs
as the fastest solution for finding them. (locate does substring matching, so no wildcards are needed)
...bearing in mind that, if you move a file, locate
won't know until the next updatedb
.
Another quick solution which will only cover stuff installed by checkinstall
or distro-provided packages but which will tell you the name of the package providing it is dpkg -S opencv_imgcodecs
.
Mine produces this output:
$ dpkg -S opencv_imgcodecs
opencv3: /usr/local/lib/libopencv_imgcodecs.so.3.2
opencv3: /usr/local/lib/libopencv_imgcodecs.so
opencv3: /usr/local/lib/libopencv_imgcodecs.so.3.2.0
(I could then get additional information by running apt-cache show opencv3
and apt-cache showpkg opencv3
)
If you really must take the slowest approach, using find
, my suggestion is to use this command:
for X in /{lib,usr/lib,usr/local/lib,home}; do find "$X" -name '*opencv_imgcodecs*'; done
It's equivalent to doing this, and will avoid wasting time checking places ... (more)