Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] Can qbs be used to compile Win32 applications?
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Can qbs be used to compile Win32 applications?

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 1 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zingam
    wrote on last edited by
    #1

    Can qbs be used to compile Win32 applications and thus Qt Creator too?

    My plan is to compile non-qt executables both on Windows (VS2013 and if possible MinGW) and then Linux (GCC, clang). Is that possible?

    I tried but I failed:
    \msvcrtd.lib(crtexe.obj):-1: error: LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zingam
      wrote on last edited by
      #2

      This is how it's done apparently:

      @
      import qbs

      CppApplication {
      type: "application" // To suppress bundle generation on Mac
      consoleApplication: true
      destinationDirectory: "../../../__build-output"

      cpp.cxxFlags: {
          if (qbs.toolchain.contains("gcc")) {
              return [ "-std=c++14" ]
          }
          else if (qbs.toolchain.contains("clang")) {
              return [ "-std=c++14"]
          }
      }
      
      cpp.linkerFlags:  {
          if (qbs.targetOS.contains("windows")) {
              if (qbs.toolchain.contains("msvc")) {
                  return [ "/subsystem:windows" ]
              }
          }
      }
      
      cpp.staticLibraries: {
          if (qbs.targetOS.contains("windows")) {
              if (qbs.toolchain.contains("msvc")) {
                  print("Loading static libraries for: Windows MSCV!")
                  return [
                              "User32.lib",
                              "kernel32.lib",
                              "gdi32.lib"
                          ];
              }
              else if (qbs.toolchain.contains("mingw")) {
                  print("Loading static libraries for: Windows MinGW!")
                  return [
                              "user32",
                              "kernel32",
                              "kernel32"
                          ];
              }
              else {
                  print("Invalid toolchain!");
              }
          }
          else if (qbs.targetOs.contains("linux")) {
              if (qbs.toolchain.contains("gcc")) {
                  print("Linux GCC is not currently supported...")
              }
              else if (qbs.toolchain.contains("clang")) {
                  print("Linux Clang is not currently supported...")
              }
          }
          else {
              print("Unsupported Target OS...")
              return []
          }
      }
      
      files: [
          "../../src/main.cpp",
          "../../src/video/windows.cpp",
          "../../src/video/windows.h",
      ]
      
      Group {     // Properties for the produced executable
          fileTagsFilter: product.type
          qbs.install: true
      }
      

      }

      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved