Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Dependency ... not found in module

I'm using opencv in my qt project, and I want to link it. But th qbs for my project does not find my opencv module. Here is my file structure:

MyProject/
├── build/
├── opencv/
│ ├── debug/
│ │ └── include/, lib/
│ ├── release/
│ │ └── include/, lib/
│ └── opencv.qbs
├── src/
│ └── main.cpp
└── MyProject.qbs <-- Main project file

Here is my opencv.qbs file :

import qbs.FileInfo
Module {
 name: "opencv"
 Export {
 Depends { name: "cpp" }
 cpp.includePaths: qbs.buildVariant == "release" ? "release/include" : "debug/include"
 cpp.libraryPaths: qbs.buildVariant == "release" ? "release/lib" : "debug/lib"
 cpp.dynamicLibraries: qbs.buildVariant == "release" ? [...files...] : [...filesd...]
 }
}

And here is MyProject.qbs:

import qbs.FileInfo
QtApplication {
 Depends { name: "Qt.widgets" }
 Depends { name: "opencv" }
 cpp.defines: [
 // You can make your code fail to compile if it uses deprecated APIs.
 // In order to do so, uncomment the following line.
 //"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0
 ]
 files: [
 "src/**",
 ]
 references: [ "opencv/opencv.qbs" ]
 install: true
 installDir: qbs.targetOS.contains("qnx") ? FileInfo.joinPaths("/tmp", name, "bin") : base
}

the line Depends { name: "opencv" } is flagged Dependency 'opencv' not found for product 'deconv'.

Answer*

Draft saved
Draft discarded
Cancel
2
  • My project is exactly as presented, however after reviewing your answer and tweaking with another clean project (which wasn't that different, it simply didn't have as many lib/include/bin files) I had to do the following : Change Module to Product, and in the top-level .qbs, pack QtApplication in the scope of Project and pull the "references" property above (and out of) QtApplication. Honestly QtCreator compile errors could be a LOT more explanatory. But thank you for your comment Commented May 19, 2025 at 14:57
  • Oops, I overlooked that the "references" was on the product level. I'll see whether we can throw an error for that. Commented May 20, 2025 at 7:26

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /