Solved Trying to import a 3rd party module
-
There's a small package available here for accessing MIDI from QML, which I am trying to use. I've successfully (I think) compiled it for Windows, and I've incorporated it into my QML application, but the
import org.komplex.qmlmidi 1.0
line gives the error messagemodule "org.komplex.qmlmidi" is not installed
.My resource tree includes:
/ org komplex qmlmidi libqmlmidi.a qmldir qmlmidi.dll
The three data files have been added to qml.qrc. The
qmldir
file containsmodule org.komplex.qmlmidi plugin qmlmidi
I have no real idea how this is supposed to work. It doesn't make sense to me that the directory containing
qmldir
would be listed inside itself, since that's a chicken-or-egg problem, but copying it into the root didn't change anything.Unfortunately, there's pretty much no documentation that goes along with this module. It's just something someone threw together five years ago.
How do I figure out what's going wrong? What does the error message really mean? What does "installed" really mean?
BTW, I also tried the "Piano" example that comes with the package, and had exactly the same problem.
-
I feel only missing information is that your directory may be missing from import paths. Add the addImportPath(...) of the directory where org.komplex.qmlmidi starts. It should solve the issue.
-
@dheerendra
Thanks. That page turned out to be useful for helping me to understand what's going on, even though I'm not going to do it that way. Since this qmlmidi model is likely to be distributed with the application, I think I'll keep it under the current directory, which is the default. When running under Qt Creator, it turns out that that's some big long subdirectory rooted next to the source subdirectory. If I copy the org/komplex/qmlmidi tree there, then it is found.However, when I built the debug version, it created another subdirectory for that, and when I copied the plugin there, it complained that I was trying to mix a debug app with a release library. That seems odd--in every other system I've worked with, it's routine to use a release version of a library with a debug version of an app, since the library has already been debugged. So, I compiled a debug version and put it there.
Then, I tried removing it from my source tree, but then got a message complaining about the lack of a rule to build the libqmlmidi.a file. So it turns out I need to have something in the source tree so that the build system doesn't think it has to build it, and manually copy it into the build tree.
So it seems that my project already has a dependency on the library, but it doesn't know how to build it. Is there some way to incorporate the qmlmidi project into my project, so that it will be invoked recursively? Or do I have to take all the bits out of the qmlmidi.pro file (SOURCES, HEADERS, etc) and manually include it in my app's .pro file? Or would it make more sense just to build qmlmidi as part of the application, and not even use a plugin library?
I was hoping I wouldn't have to learn the nuts and bolts of the build system...
Eventually, I suppose I'll have more head scratching to do when I try to deploy the app. But I have quite a bit more writing and debugging to do within Qt Creator before I get to that point.
-
In summary you would like to build the library before building your app. Under QtCreator you can specify the build order under project->project settings->Dependencies. This it will build the dependent library first. In your case app depends on the library. You can put this dependency.
-
Actually, since the qmlmidi package is only three source files and five headers, it turned out to be really easy just to include them as part of my project, and not even bother with making a plugin. Since it's so tiny, I'm not even sure why the author though it helpful to make it a plugin in the first place.
-
May he thought of extending this later & make it as reusable component. Also once he makes it as plugin, it can changed independently. Any way it is good that everything worked. Enjoy.