Solved QLibrary: isLoaded() not matching!
-
Here is a simple example of my main C++ application that loads my custom shared library called "mylib.so.1.0.0" that is placed in the same folder of the main application.
The wired thing is that: In the console output it said that themylib
was not loaded, but it can call and execute therun()
function that is inside the shared library.QLibrary mylib("./mylib"); std::cout << "Is Loaded: " << mylib.isLoaded() << std::endl; std::cout << mylib.errorString().toStdString() << std::endl; typedef void (*func_run)(void); func_run run = (func_run) mylib.resolve("run"); if (run == NULL) { std::cerr << "[API ERROR]: Unable to load the run() function!" << std::endl; exit(1); } run(); // WORKS GOOD!
Console Output:
Is Loaded: 0 // <-- WHY? Unknown error Shared Library: Inside the RUN() function
My System:
- Ubuntu 20.04 x64
- CMake 3.16.3
- g++ 9.3
- Qt 5.15.1
-
@fem_dev I solve...To get a right result of
isLoaded()
you must callload()
before it! -
@fem_dev I solve...To get a right result of
isLoaded()
you must callload()
before it! -
To get a right result of
isLoaded()
you must callload()
before it!I think that's not true, the result of
isLoaded()
is right during the whole time.
When you haven't calledload()
, it is not loaded, soisLoaded()
should return false.