Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtPluginLoader fails to load plugin if I use Tensorflow functions in it



  • I am making a plugin as a project in Visual Studio 2017 which loads a Tensorflow model and uses it in an application. The plugin includes a class which loads a Tensorflow model and links with Tensorflow 1.7 (built for Release, I also build the plugin for Release). If I comment out all of the functions and structures from the Tensorflow library (e.g., tensorflow::GraphDef, etc.) then the plugin loads. If I uncomment them it fails to load:

    QPluginLoader *loader = new QPluginLoader(pluginsDir.absoluteFilePath(pluginPath));
    QObject *plugin = loader->instance(); // plugin is NULL
    

    plugin->errorString() is

    "CNNPlugin.dll" "Cannot load library ...\\bin\\Release\\plugins\\CNNPlugin.dll: The specified module could not be found."
    

    But it is there, and it loads just fine if I comment out all Tensorflow related code as mentioned. I tried linking with and running tensorflow in a simple C++ console application and that worked without issue.


  • Qt Champions 2019

    Make sure the TensorFlow library is in your Path when trying to load the library.


  • Moderators

    @fugreh said in QtPluginLoader fails to load plugin if I use Tensorflow functions in it:

    But it is there, and it loads just fine if I comment out all Tensorflow related code as mentioned.

    To clarify @Christian-Ehrlicher's comment: Qt can't load your plugin if it can't find the TensorFlow libraries

    I tried linking with and running tensorflow in a simple C++ console application

    In this test, how did you tell Qt where to find the TensorFlow libraries?



  • Thanks for your input, the problem was that the DLL was actually not in the place where it should have been, my mistake.