Problem Description: after the compilation is successful (there is an executable file in the folder), an error is reported when running (Ubuntu) clip, and the error cannot be found So shared library (but shell can execute normally) solution (similar error reporting in pycharm)
/home/luoxinhao/Desktop/mywork/bin/Infantry: error while loading shared libraries: libopencv_features2d.so.4.5: cannot open shared object file: No such file or directory
Reason: the execution of clion may be different from the environment variables of our shell. The following is the solution
Method 1: each time you start the clion, use the terminal to enter the folder where the clion is located and input/clion.SH, it can be executed normally. (feasible but troublesome)
Method 2: soft link method (both shell error reporting and idle error reporting are feasible, but many libraries may need to be linked, one by one)
My clion was successfully modified in this way, but pycharm gave up seven or eight links without completing the chain
1.1 find files
find / -name lib**. So (missing DLL)
1.2 establishing soft links
ln -s /path/to/lib**. so /usr/lib
1.3 sudo ldconfig
Method 3: modify LD_LIBRARY_Path (for me, it can only solve the shell error, and the modified idle still reports an error)
sudo gedit ~/. bashrc
export LD_LIBRARY_PATH=/where/you/install/lib:$LD_LIBRARY_PATH
sudo source ~/.bashrc
Method 4: modify/etc/LD so.Conf (ibid.)
vim /etc/ld.so.conf
add /where/you/install/lib
sudo ldconfig
Method 5: add it to the environment variable (available, used to solve the error reported by idle, which may need to be used in conjunction with method 3, without separate attempt)
First, open pycharm and modify the environment variable of the running configuration in the upper right corner
If you already have an environment variable, type a semicolon after it and paste it.
Paste content is similar to method 3
For example, method 3 is as follows
export LD_LIBRARY_PATH="/opt/intel/openvino_2021.4.689/opencv/lib:$LD_LIBRARY_PATH"
Then add after the semicolon
LD_LIBRARY_PATH=/opt/intel/openvino_2021.4.689/opencv/lib