Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Can't run First Program

Can't run First Program

Scheduled Pinned Locked Moved Solved Installation and Deployment
4 Posts 3 Posters 461 Views
  • 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.
  • C Offline
    C Offline
    CarlosCz25
    wrote on last edited by
    #1

    Hi there,

    I am trying to run my first Hello World program with Qt. And it's being a true nightmare.

    I am using the Qt tools provided by the online installer from Qt for its version 6.4.2.

    IDE is VSCode.

    The main file I try to build and run is test.cpp:

    #include <iostream>
    #include <iterator>
    #include "neuron.h"
    #include "accessory_functions.h"
    
    #include <QtWidgets/qapplication.h>
    #include <QtWidgets/qpushbutton.h>
    
    int main(int argc, char **argv){
    
        QApplication a( argc, argv );
    
        QPushButton hello( "Hello world!", 0 );
        hello.resize( 100, 30 );
    
        
        hello.show();
        return a.exec(); 
    
    
       
        
    }
    

    and the tasks.json file to build the active file loos as follows:

    {
        "tasks": [
            {
                "type": "cppbuild",
                "label": "C/C++: g++.exe build active file",
                "command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe",
                "args": [
                    "-fdiagnostics-color=always",
                    "-g",
                    "${file}",
                    "-o",
                    "${fileDirname}\\${fileBasenameNoExtension}.exe",
                    "-IC:/Qt/6.4.2/mingw_64/include",
                    "-LC:/Qt/6.4.2/mingw_64/bin/",
                    "-lQt6Widgets",
                    "-lQt6Core"              
                ],
                "options": {
                    "cwd": "C:\\Qt\\Tools\\mingw1120_64\\bin\\"
                },
                "problemMatcher": [
                    "$gcc"
                ],
                "group": "build",
                "detail": "compiler: C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe"
            }
        ]
    }
    

    Now the buld runs fine. But when running the program I get the error:

    "The code execution cannot proceed because Qt6Widgets.dll (and another for Qt6Core.dll) was not found. Reinstalling the program may fix this problem."

    Well, files are obviously at the location the are presumed to be (-L location in the build call)

    The curious thing is that if I start placing the dll files next to the build executable the error message changes, hence asking for related dependencies I guess. So I have something very wrong with my Qt installation I guess. Or may it be related to the build process I am following.

    Any help is greatly appreciated.

    Thanks in advance,
    Carlos.

    JonBJ JoeCFDJ 2 Replies Last reply
    0
    • C CarlosCz25

      Hi there,

      I am trying to run my first Hello World program with Qt. And it's being a true nightmare.

      I am using the Qt tools provided by the online installer from Qt for its version 6.4.2.

      IDE is VSCode.

      The main file I try to build and run is test.cpp:

      #include <iostream>
      #include <iterator>
      #include "neuron.h"
      #include "accessory_functions.h"
      
      #include <QtWidgets/qapplication.h>
      #include <QtWidgets/qpushbutton.h>
      
      int main(int argc, char **argv){
      
          QApplication a( argc, argv );
      
          QPushButton hello( "Hello world!", 0 );
          hello.resize( 100, 30 );
      
          
          hello.show();
          return a.exec(); 
      
      
         
          
      }
      

      and the tasks.json file to build the active file loos as follows:

      {
          "tasks": [
              {
                  "type": "cppbuild",
                  "label": "C/C++: g++.exe build active file",
                  "command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe",
                  "args": [
                      "-fdiagnostics-color=always",
                      "-g",
                      "${file}",
                      "-o",
                      "${fileDirname}\\${fileBasenameNoExtension}.exe",
                      "-IC:/Qt/6.4.2/mingw_64/include",
                      "-LC:/Qt/6.4.2/mingw_64/bin/",
                      "-lQt6Widgets",
                      "-lQt6Core"              
                  ],
                  "options": {
                      "cwd": "C:\\Qt\\Tools\\mingw1120_64\\bin\\"
                  },
                  "problemMatcher": [
                      "$gcc"
                  ],
                  "group": "build",
                  "detail": "compiler: C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe"
              }
          ]
      }
      

      Now the buld runs fine. But when running the program I get the error:

      "The code execution cannot proceed because Qt6Widgets.dll (and another for Qt6Core.dll) was not found. Reinstalling the program may fix this problem."

      Well, files are obviously at the location the are presumed to be (-L location in the build call)

      The curious thing is that if I start placing the dll files next to the build executable the error message changes, hence asking for related dependencies I guess. So I have something very wrong with my Qt installation I guess. Or may it be related to the build process I am following.

      Any help is greatly appreciated.

      Thanks in advance,
      Carlos.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @CarlosCz25 said in Can't run First Program:

      Well, files are obviously at the location the are presumed to be (-L location in the build call)

      Sorry I don't know about the "installer". But that -L is to be used while building a Qt executable. When you run the executable it always has to find the .dll files it needs, either along PATH or in the same directory as the executable, hence your

      The curious thing is that if I start placing the dll files next to the build executable the error message changes

      I don't know about "VS" stuff, but people usually use windeployqt to package and deploy their programs (plus dependent DLLs).

      1 Reply Last reply
      1
      • C CarlosCz25

        Hi there,

        I am trying to run my first Hello World program with Qt. And it's being a true nightmare.

        I am using the Qt tools provided by the online installer from Qt for its version 6.4.2.

        IDE is VSCode.

        The main file I try to build and run is test.cpp:

        #include <iostream>
        #include <iterator>
        #include "neuron.h"
        #include "accessory_functions.h"
        
        #include <QtWidgets/qapplication.h>
        #include <QtWidgets/qpushbutton.h>
        
        int main(int argc, char **argv){
        
            QApplication a( argc, argv );
        
            QPushButton hello( "Hello world!", 0 );
            hello.resize( 100, 30 );
        
            
            hello.show();
            return a.exec(); 
        
        
           
            
        }
        

        and the tasks.json file to build the active file loos as follows:

        {
            "tasks": [
                {
                    "type": "cppbuild",
                    "label": "C/C++: g++.exe build active file",
                    "command": "C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe",
                    "args": [
                        "-fdiagnostics-color=always",
                        "-g",
                        "${file}",
                        "-o",
                        "${fileDirname}\\${fileBasenameNoExtension}.exe",
                        "-IC:/Qt/6.4.2/mingw_64/include",
                        "-LC:/Qt/6.4.2/mingw_64/bin/",
                        "-lQt6Widgets",
                        "-lQt6Core"              
                    ],
                    "options": {
                        "cwd": "C:\\Qt\\Tools\\mingw1120_64\\bin\\"
                    },
                    "problemMatcher": [
                        "$gcc"
                    ],
                    "group": "build",
                    "detail": "compiler: C:\\Qt\\Tools\\mingw1120_64\\bin\\g++.exe"
                }
            ]
        }
        

        Now the buld runs fine. But when running the program I get the error:

        "The code execution cannot proceed because Qt6Widgets.dll (and another for Qt6Core.dll) was not found. Reinstalling the program may fix this problem."

        Well, files are obviously at the location the are presumed to be (-L location in the build call)

        The curious thing is that if I start placing the dll files next to the build executable the error message changes, hence asking for related dependencies I guess. So I have something very wrong with my Qt installation I guess. Or may it be related to the build process I am following.

        Any help is greatly appreciated.

        Thanks in advance,
        Carlos.

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        @CarlosCz25 Note that build path and running path are two different things. Do not mix them up. -L in tasks.json sets the lib path for build only. When your app runs, it looks for the libs in the environment paths.

        C 1 Reply Last reply
        1
        • JoeCFDJ JoeCFD

          @CarlosCz25 Note that build path and running path are two different things. Do not mix them up. -L in tasks.json sets the lib path for build only. When your app runs, it looks for the libs in the environment paths.

          C Offline
          C Offline
          CarlosCz25
          wrote on last edited by
          #4

          @JoeCFD
          Hi Joe,

          great advise.
          Adding the qt dll's path to the path variable did the trick.

          Many thanks.

          Carlos.

          1 Reply Last reply
          0
          • C CarlosCz25 has marked this topic as solved on

          • Login

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