How To Setup 64-Bit Qt 5 With NetBeans 7.4 On Windows
Contributed By: Mark Wilmoth
I will show you how to setup 64-bit Qt 5.1.1 on Windows to use with NetBeans 7.4.
JDK 7 update 25 and NetBeans 7.4 is required. This will not work on previous versions of NetBeans. This will work on NetBeans nightly development builds 201308310001 or newer. I will not go over installing these as it is clearly documented.
There is no 64-bit Qt 5.1.1 Windows builds on the qt-project.org website at the time of this writing, but there is a 64-bit Windows build, including MinGW64, that you can download from MinGW-builds' sourceforge page. At the time of this writing, the latest package name to download is x64-Qt-5.1.1+qtcreator-2.8.1-(gcc-4.8.1-seh-rev5).7z.
You will also need to download MSYS GNU make.exe. A newer version of MSYS can be downloaded from MinGW-builds' sourceforge page.
One last thing you will need, is to download 7zip and install it, because the packages from MinGW-builds are 7z format.
- Once you have download the Qt64 7zip package, extract it to a convenient place on your computer. We will extract it to C:\Developer\Qt64\. There will 3 directories to extract, Qt64-5.1.1, mingw64 and ported64.
- Now extract the MSYS 7zip package to C:\Developer\msys\.
- Next we need to add the path to the Qt64-5.5.1, MinGW64 and MSYS bin folders. To do this in Windows 7, go to the Start Menu and search "advanced system" and click on "View Advanced System Settings". Then click on the "Environment Variables" button.
- Now you can enter the folder paths directly in the system path, but I like to create three variables QT_MINGW_HOME, QT_HOME and MSYS_HOME for these paths (omitting the bin folder) and then adding those variables to the path string. In our case Qt_HOME is C:\Developer\Qt64\Qt-5.1.1, QT_MINGW_HOME is C:\Developer\Qt64\MinGW64 and MSYS_HOME is C:\Developer\msys. Do not add a backslash at the end!
- Next, edit the PATH variable and add %QT_HOME%\bin;%QT_MINGW_HOME%\bin;%MSYS_HOME%\bin at the end.
- Check to see if the Qt64, MinGW64 and MSYS paths are valid by entering path in the Windows command prompt interpreter cmd.exe. Do not include any other paths to build tools of the same name before these new entries or your builds will fail!
- Check to see if qmake.exe, g++.exe and make.exe is accessible by typing qmake --version, gcc --version and make --version in the Windows command prompt from a folder outside of where they are located. You may continue to do the same for the rest of the tools gcc.exe, gfortan.exe, as.exe and gdb.exe.
- Next, in the Windows command prompt, navigate to C:\Developer\Qt64\Qt64-5.1.1 folder and run qtbinpatcher --nobackup to set the internal path in the Qt64 binaries. You should get a "Patch successfully complete." message when done.
Setting up the Build Tools in NetBeans
- Now you should already have NetBeans installed and have installed the full package—in which you can just activate C/C++ through Options—or you will have to install the C/C++ plugin with the NetBeans plugin manager.
- Go to Tools >> Options >> C++ and you will see the build tools panel. If NetBeans has not already found the standard build tools automatically, you will need to add them manually. To add the build tools, click the "Add..." button and then add the path to the bin folder.in which you can just activate C/C++ through Options—or you will have to install the C/C++ plugin with the NetBeans plugin manager.
- Go to Tools >> Options >> C++ and you will see the build tools panel. If NetBeans has not already found the build tools automatically, you will need to add them manually. To add the build tools, click the "Add..." button and then add the path to the bin folder.
- You will now see a tool collection in the Build Tools panel.
- To test this, we will create a sample Qt project. Go to File >> New Project >> Categories: Samples: C/C++, Project: Hello Qt World. Click the Next button and accept all the default settings by clicking the Finish button.
- You will now see the new project in the NetBeans Project Window. Press F11 on your keyboard to build the project. The project should have built successfully and you will see a "successful" message in the NetBeans output window.
- Press F6 on your keyboard to run the project. You should see a "Hello Qt World" dialog box come up with a field prompting you to enter your name. Enter something and then click the red x in the upper right hand corner of the dialog box to close the program. You will then see a "run successful" message in the NetBeans output windows.
- At this point, you may want to look at some of the files in the project. If you see a little question mark on the project's Qt icon in the Projects window and error badges on the files, right click on the project name and choose Code Assistant >> Reparse Project and they will go away.
- To run the Qt Designer so you can modify or create a new form, look in the project's Resource Files folder in the NetBeans Project Window. Right click on the file name HelloForm.ui and choose Open. The Qt Designer will run and show you the project form.
- Now you are up and running!