0

Please help me.

I have a static lib builded with qt earlier, and it uses Qt libs. And the next app is compilable in qbs 1.11 versions and isn't in new qbs 1.12:

Application {
    qbsSearchPaths: "path_to_my_modules"
    Depends { name: "Qt.widgets"  }
    Depends { name: "mylibs.mylib" }
    files: "main.cpp"
}

On the linking step it outs multiple errors, kind of:

undefined reference to `_imp___ZN7QString6appendERKS_'
undefined reference to `_imp___Z18qSetMessagePatternRK7QString'

... etc.

the module mylib looks like:

import qbs

Module {
    Depends { name: "cpp" }
    cpp.includePaths: path
    cpp.staticLibraries: path + "/libmylib.a"
}

Is it a bug, or I need to do some corrections?

Trying to link on Windows 10 (64bit) with Qt Creator 4.6 and 4.7 rc for old and new qbs versions respectively.

Alex Nevskiy
  • 347
  • 1
  • 2
  • 10

1 Answers1

1

The problem here is that qbs cannot know that mylib has a Qt dependency. It may have accidentally worked for you in previous versions, but that was just luck. Rewriting your module should help:

Module {
    Depends { name: "Qt.core" } // Or whatever modules mylib uses
    Group {
        filesAreTargets: true
        fileTags: "staticlibrary"
        filePath: path + "/libmylib.a"
    }
}
  • _It is_: linking qbs_1.exe [qbs_1] C:/Qt/Qt5.11.1/Tools/mingw530_32/bin/g++.exe "-Wl,-m,i386pe,-subsystem,windows,--major-subsystem-version,5,--minor-subsystem-version,01,--major-os-version,5,--minor-os-version,01" -LC:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib -m32 -o D:/qt/temp/_build/qbs_1/Release_windows_Qt_5_11_1_MinGW_32bit/qtc_windows_Qt_5_11_1_MinGW_32bit_release/qbs-1.dba52c92/qbs_1.exe D:/qt/temp/_build/qbs_1/Release_windows_Qt_5_11_1_MinGW_32bit/qtc_windows_Qt_5_11_1_MinGW_32bit_release/qbs-1.dba52c92/3a52ce780950d4d9/main.cpp.o – Alex Nevskiy Jul 07 '18 at 08:59
  • _continue_: C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libQt5Widgets.a C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libQt5Gui.a C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libQt5Core.a C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libqtmain.a D:/qt/xlibs/products/0_5_0/windows_Qt_5_11_1_MinGW_32bit_release/modules/mylibs/mylib/libmylib.a – Alex Nevskiy Jul 07 '18 at 09:00
  • Linker command line differs from the old version in order of including ot the libs. The old order was: C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libqtmain.a D:/qt/xlibs/products/0_5_0/windows_Qt_5_11_1_MinGW_32bit_release/modules/mylibs/mylib/libmylib.a C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libQt5Core.a C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libQt5Gui.a C:/Qt/Qt5.11.1/5.11.1/mingw53_32/lib/libQt5Widgets.a may be the linking order have made an effect. – Alex Nevskiy Jul 07 '18 at 09:14
  • Thank you! It works. You mean, of course, _files: path + "/libmylib.a"_ instead of _filepath_ inf Group item. – Alex Nevskiy Jul 07 '18 at 10:46
  • It doesn't require even _Depends { name: "Qt.core" }_ part. – Alex Nevskiy Jul 07 '18 at 10:58
  • Again, it might happen to work because you have the Qt dependency elsewhere. But for correctness and to be on the safe side, you should still declare it in the module (it's not self-contained otherwise). – Christian Kandeler Jul 07 '18 at 19:07