User forums > Using Code::Blocks

Error while loading shared library

<< < (3/3)

gd_on:
I used Linux in the past ...
Search in google LD_LIBRARY_PATH
For example : https://stackoverflow.com/questions/68298985/how-to-set-ld-library-path-permanently
Apparently, setting/modifying this variable globally (in .bashrc or .profile) is not always a good thing.
There are other ways with ldconfig. Linux specialists will certainly have a better advice...

jordi:
As linuxMint is based on Debian, I assume the paths and files are the same in your system

--- Code: ---jordi@debian:/etc$ ll ld.so.conf
-rw-r--r-- 1 root root 34 Jul 29  2019 ld.so.conf
jordi@debian:/etc$ cat ld.so.conf
include /etc/ld.so.conf.d/*.conf

jordi@debian:/etc$ cd ld.so.conf.d/
jordi@debian:/etc/ld.so.conf.d$ ll
total 16
-rw-r--r-- 1 root root  38 Nov 10  2020 fakeroot-x86_64-linux-gnu.conf
-rw-r--r-- 1 root root  44 Jul 29  2019 libc.conf
-rw-r--r-- 1 root root 100 May  1  2021 x86_64-linux-gnu.conf
-rw-r--r-- 1 root root  56 Oct  2  2021 zz_i386-biarch-compat.conf
jordi@debian:/etc/ld.so.conf.d$ cat libc.conf
# libc default configuration
/usr/local/lib

--- End code ---
Create a .conf file for opencv and add the path where the libraries are (as the content in libc.conf file)

Command to update changes done in configuration files (you will need super-user privileges).
sudo /usr/sbin/ldconfig -v
Maybe it doesn't work for you. Search how to execute commands as superuser in linuxMint

Example: command to see all the dynamic libraries whick contains the "open" word

--- Code: ---jordi@debian:/etc/ld.so.conf.d$ /usr/sbin/ldconfig -p | grep -i open
libopensc.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libopensc.so.7
libopenmpt.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libopenmpt.so.0
libopenjp2.so.7 (libc6,x86-64) => /lib/x86_64-linux-gnu/libopenjp2.so.7
libopencore-amrwb.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libopencore-amrwb.so.0
libopencore-amrnb.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libopencore-amrnb.so.0
libopenal.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libopenal.so.1
libOpenNI2.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libOpenNI2.so.0
libOpenGL.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libOpenGL.so.0
libOpenGL.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libOpenGL.so
libOpenCL.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libOpenCL.so.1

--- End code ---

mihasic:
I beg your pardon once again, I thought it was a CodeBlocks forum. I chose CodeBlocks in order to simplify the creation of my applications. I know very well that C++ code can be compiled and linked without using an IDE, directly with system commands. If it is simpler than with CodeBlocks, then what is the reason for CodeBlocks to exist?

sodev:
As you said yourself, your application does compile fine, so you don't have a compile time problem. You have a runtime problem. Changing the compiler configuration will do nothing, because your application is not RUN by the compiler but by your OS, Linux in your case.

Actually, your problem is not a CodeBlocks problem but a Linux problem, so technically offtopic here. If you stop beeing so ignorant you still might get some help here.

There are multiple ways to configure the Linux dynamic library loader. If you install libraries with the package manager this should not be necessary and should just work, so the first question is, how did you actually get OpenCV on your system? Second question is, is it really OpenCV that is missing or might this library itself miss something else? To answer that question, run
--- Code: ---ldd <your-application-binary-goes-here>
--- End code ---
and post the output.

mihasic:

--- Quote from: sodev on December 01, 2022, 09:20:22 pm ---As you said yourself, your application does compile fine, so you don't have a compile time problem. You have a runtime problem. Changing the compiler configuration will do nothing, because your application is not RUN by the compiler but by your OS, Linux in your case.

Actually, your problem is not a CodeBlocks problem but a Linux problem, so technically offtopic here. If you stop beeing so ignorant you still might get some help here.

There are multiple ways to configure the Linux dynamic library loader. If you install libraries with the package manager this should not be necessary and should just work, so the first question is, how did you actually get OpenCV on your system? Second question is, is it really OpenCV that is missing or might this library itself miss something else? To answer that question, run
--- Code: ---ldd <your-application-binary-goes-here>
--- End code ---
and post the output.

--- End quote ---
Frankly speaking, I don't like you being so aggressive, but nevertheless, I will answer.
- I believed that CodeBlocks was an IDE, not just a compiler. IDE, as I understand it, not only compiles, but also guides the whole build process, including linking. As far as I see, my problem is that the linker does not find the libraries, although I filled-in in the CodeBlocks interface all the fields I could find that seemed related to linker configuration. If, as you say, the 'Linux dynamic library loader' is not configured after that, I believe it an IDE bug. Or I may be missing something in the IDE interface - that was my question.
- As for the installation, in Mint there is a list of applications that can be installed by the system automatically, I made confidence to this option.
- As for your hypothesis that it could be something wrong in the library itself, I don't think it could be the case. First, the message at run time clearly says that the required file could not be found. I think that kind of message is produced before accessing the file in question.  Second, as I have already reported, I tried to explore the problem with model dummy libraries, produced with this very CodeBlocks installation, and it gave exactly the same result.

Anyhow, I see the problem is really complicated, I apologize for bothering the forum with it. Thanks to all who tried to help me and good luck.

Navigation

[0] Message Index

[*] Previous page

Go to full version