Qt6.4 not finding library
-
wrote on 8 Aug 2022, 10:52 last edited by Colins2 8 Aug 2022, 10:53
I have a puzzling problem.
I have just installed Linux Mint 21 - no upgrade path available, so a new clean install.
I installed Qt 6.4 -new install also.
I am working on an OpenGL tutorial and so have various GL libraries installed in /usr/local/lib64
I have set $LD_LIBRARY_PATH to include that directory and it prints out from an echo command in a terminal window.
I can compile my program with no errors and I can run it from the debug directory in a terminal window and it works as it is supposed to. I.E. it finds the required libraries.
When I try to run it from within QtCreator I get an error that one of the shared libraries cannot be found.
I tried creating a qt.conf file but the documentation is not very clear where this file should be and so far it has no effect.
I was doing this course with a previous installation of Qt and Linux Mint 20.3 and it all worked fine. I could run the app as I was following the course from within QtCreator.Any suggestions please?
Colin -
wrote on 8 Aug 2022, 12:36 last edited by
@Colins2 said in Qt6.4 not finding library:
When I try to run it from within QtCreator I get an error that one of the shared libraries cannot be found.
What is the exact error that you are getting?
-
wrote on 8 Aug 2022, 13:30 last edited by
This what I get in the Qt generated terminal window:
/home/colins2/GL-Projects/OpenGL_course/build-29-Point-Lights-Desktop_Qt_6_4_0_GCC_64bit-Debug/29-Point-Lights: error while loading shared libraries: libglfw.so.3: cannot open shared object file: No such file or directory
Press <RETURN> to close this window...
<<
libglfw.so.3 is a symbolic link to libglfw.so.3.4 (the complied library) and it is in /usr/local/lib64 - all the GL libraries are in there.
LD_LIBRARY_PATH is exported with this value.When I simply run the executable file, in this case 29-Point-Lights, from a terminal window, it works fine, so the library is good and the path to the library is good. The file runs without errors.
It just will not run in the Qt Creator terminal for some reason. It would seem that QtCreator does not read the LD_LIBRARY_PATH variable.
Colin -
wrote on 9 Aug 2022, 03:40 last edited by
Solved - sort of?
Instead of linking to the shared library, I have now linked to the static library and it magically works from the QtCreator terminal.
Both the static library, libglfw3.a and the shared library libglfw.so.3 are in the same directory.
The directory is both in my $PATH and in $LD_LIBRARY_PATH but the QtCreator terminal doesn't find them.
Interestingly, it does find libGL.so which is in /usr/lib/x86_64-linux-gnu. -
wrote on 9 Aug 2022, 08:17 last edited by
If you run
ldd /usr/local/lib64/libglfw.so.3
do you get unresolved dependencies? -
wrote on 9 Aug 2022, 10:29 last edited by
@ChrisW67
No, I get no errors there.
Similarly, if I run ldd ./29-Point-Lights from the build directory, I get no errors. I did get a not found error prior to exporting the $LD_LIBRARY_PATH but that fixed it.
This is only a problem from the QtCreator generated terminal, not a terminal that I open.As I posted above, compiling against a static library instead, it works fine.
There is obviously nothing wrong with the shared library as it works from the command line.
There must be a simple explanation, I just can't find it.
As this is a course and only for my personal use, it doesn't matter in this case but I'd still like to find the reason.
1/6