Author Topic: Has anybody gotten Qt5 to work with Code::Blocks on Windows?  (Read 34241 times)

Offline onesteplower

  • Multiple posting newcomer
  • *
  • Posts: 12
Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« on: September 22, 2013, 03:16:45 am »
I've been at it all day trying to get this to work.  None of the instructions out there actually mention paths that exist, so it has been a guessing game.  I've used the x64 installer on Windows, and I've tried the only ...\lib, ...\include, and ...\bin directories it has in all combinations in both the linker search directory in Code::Blocks and the PATH environmental variable, and still #include <QtBase> and #include “activeqtversion.h” lead to a compile error that says the file can't be found.

I've made a topic on the Qt forums, but I'm trying here too because I honestly don't even know if I'll get a response there.  Since there are absolutely no installation instructions whatsoever that are not outdated and invalid, I'm at a complete standstill.  The only two topics I could find on this forum are also not answered.  Is it even possible to use Qt without being hamstrung into using their IDE?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #1 on: September 22, 2013, 03:23:44 am »
Read the CB FAQs; it will NOT tell you how to use Qt in CB; but, should help you get rid some of the current errors you are complaining about.

http://wiki.codeblocks.org/index.php?title=Main_Page

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline onesteplower

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #2 on: September 22, 2013, 03:27:50 am »
(Big Edit) I'm tidying this up since the info herein is growing and it's too wordy.  There are many problems with installation directions out there.

Step 1: Get the SDKs and compilers.

C::B Wiki Problem 1: The "Platform SDK" mentioned in the Wiki is ambiguous.  Which platform SDK?  Windows?  DirectX?  
C::B Wiki Problem 2: The link to the "Platform SDK" is broken.

Here's the correct link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=6510

Do a custom installation so you can automate setting environmental variables.

C::B Wiki Problem 3: You will need an additional SDK to that described in the C::B Wiki, but you can get your VS compiler set up in this step too.  

You will need the DirectX SDK later.  Lookie here: https://www.microsoft.com/en-us/download/details.aspx?id=6812

NOTE: Install the DirectX SDK BEFORE going through the VS 2010 installation steps.  

...and then use this page -- http://qt-project.org/doc/qt-5.0/qtdoc/requirements-win.html  

Unless you plan on developing apps for Metro in Windows 8, get the version 7.1 SDK.  Follow the installation order instructions or you'll be doing it over again later!

Step 2: Install Active Perl -- http://www.activestate.com/activeperl

The newest installers include an option to set environmental variables for you.

Step 3: Install MiniGW -- http://sourceforge.net/projects/mingw/files/latest/download

Get the developer toolkit package, and the latest GCC.  AFTER those install, install the MiniGW base.  There will be conflicts because your Code::Blocks installation includes a DLL version, but this will ensure that you have the bin directory we'll be adding to the environmental variable in a moment.

Follow the instructions here: http://wiki.codeblocks.org/index.php?title=MinGW_installation except for the environmental variable part (we'll do that below).

After changing the line in fstab as mentioned in those instructions, make sure that the line below it is the path to your Perl library.  For me, this is D:\Perl64\lib, as in the newest x64 Active Perl for Windows, there is no "ActiveState" directory.  

Step 4: Catch up your environmental variables.  

a. Right click "My Computer," and click "Properties."  
b. In the "Advanced" tab, click the button "Environmental Variables".
c. Click the "Path" key and click "Edit".
d. Add ;(installation drive)\msys\1.0\bin to the end for msys.
e. Add ;(installation drive)\MiniGW\bin
e. Click "OK".

Note: Replace (installation drive) with the drive you installed to; e.g. "C:\", "D:\"
Note: Mind the semicolon before each entry.

Step 5: Developer Tools

a. http://www.python.org/download/

The installer has an option to update PATH for you.

b. http://rubyinstaller.org/downloads/

The installer automatically updates the PATH environmental variable.

c. Get jom and set C::B to use it.

http://qt-project.org/wiki/jom

i. Open the zip and copy the contents to clipboard.
ii. Open C::B and go to settings --> compiler
iii. Select Microsoft Visual Studio C++ 2010.  If it's not there, reinstall Code::Blocks and the installer will set everything up for you.
iv. Go to Toolchain Executables --> Program Files --> Make Program
v. Click the "..." button, and paste the contents of the jom zip into the directory that opens.
vi. Select jom.exe and click open and then ok.

Step 6: Libraries

a. Get ICU -- http://site.icu-project.org/download/51

i. Extract the contents of the zip of the location of your choice.
ii. Add to the PATH environmental variable ;(extraction drive)\icu\bin64  
iii. Add to the LIB environmental variable ;(extraction drive)\icu\lib64
iv. Add to the INCLUDE environmental variable ;(extraction drive)\icu\include

Let me take a moment to blabber at this point that the Qt installer directions are totally FUBAR because it doesn't update the environmental variables for the benefit of this library and the directions make no mention of it.  Don't trust their installer to do its job.  True story.  (Looks like I found my problem's source, but I started this and I will finish it).

b. ANGLE -- https://code.google.com/p/angleproject/wiki/DevSetup

Follow the instructions there, using Visual Studio 2010 as described on that page.  I just spent a little time trying to find a quick way to be sure the process could be done from within Code::Blocks, but it appears to require the Visual Studio 2010 Express debugger, and Code::Blocks does not appear to support it at this time.  Plus there are some IDE interface differences that I don't want to guess about.

c. Extra Tools

Bison and Flex are already in your msys bin folder, so you will need GPerf -- http://sourceforge.net/projects/gnuwin32/files/gperf/3.0.1/gperf-3.0.1.exe/download?use_mirror=hivelocity&download=

(more edits incoming with more instructions -- I need a quick break)

Final Step: Swim three laps across the English Channel at midnight, and report back at 0-dark-thirty wearing the skin of a seduced gryphon, and you should be done!
« Last Edit: September 22, 2013, 06:12:54 am by onesteplower »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #3 on: September 22, 2013, 06:22:05 am »
Build command used with files installed by qt-windows-opensource-5.1.1-mingw48_opengl-x86-offline.exe into folder C:\Apps\Qt
Code
i686-w64-mingw32-g++.exe -Wall -g -IC:\Apps\Qt\Qt5.1.1\5.1.1\mingw48_32\include -IC:\Apps\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtGui -IC:\Apps\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtWidgets -c V:\SourceCode\CBProjects\TestProjects\testqt5\main.cpp -o obj\Debug\main.o
i686-w64-mingw32-g++.exe -LC:\Apps\Qt\Qt5.1.1\5.1.1\mingw48_32\lib -o bin\Debug\testqt5.exe obj\Debug\main.o   -lQt5Core -lQt5Gui -lQt5Widgets

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline onesteplower

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #4 on: September 22, 2013, 07:04:41 am »
It still can't find the headers, after everything is updated in your commands for my system.  Nada, as if they don't exist.  This is with all three environmental variables set: PATH to \bin, LIB to \lib, and INCLUDE to \include.  I've also tried the library finder plugin, and it says "waiting" indefinitely and then freezes when I click stop.  The task manager has to be used to end Code::Blocks at that point.

C::B seems to simply refuse to acknowledge that Qt exists, and I really can't find anything that's not configured.

edit: VisualC++ can't find the headers either, and everything is configured.  I've gone over it over and over and have almost written a complete step by step above to show it.  I'm starting to think that the newest version of Qt is designed to prevent its use in anything but their IDE.

final edit to this post: I'm going to try and reinstall Qt.  I don't know what could be wrong when all of the physical files are present, environmental variables are set, and Qt Creator runs and compiles fine.  Maybe there's a registry entry that wasn't properly set or something.  Whatever the case, I've been looking at a LOT of posts about Qt today and it seems that some people love it and some absolutely despise it, with very little middle ground.  I can see why...
« Last Edit: September 22, 2013, 07:24:56 am by onesteplower »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #5 on: September 22, 2013, 07:30:37 am »
Did you include the QtWidgets folder in the search path as I needed to do to get MinGW GCC to compile?

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Tim S.
« Last Edit: September 22, 2013, 08:02:55 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline onesteplower

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #6 on: September 22, 2013, 08:34:51 am »
(Big edit, slimmed down the post but it has the same stuff)

Roger that, but I'm zeroing in on the problem.  It seems to have been a compound issue.  After reinstalling Qt, I get a message that libgmp-32.dll isn't on my system when I try to compile from commandline.  It's not in D:\minigw32\bin as it should be, but it IS in D:\bin.  I've got both in the path and PATH environmental variables for good measure, with no luck.  The system doesn't see it in the folder D:\bin.

update:

I happened upon this: http://mingw-users.1079350.n2.nabble.com/Question-libgmp-10-dll-not-found-td7443661.html

Now, it's weird that I didn't see this before when I tried the command line.  I wonder if the previous Qt install messed with mingw somehow.

The installer on the mingw page I linked above (the one that behaves like a Linux package manager) installed two sets of mingw folders: one set with all the files on the root directory, and another set missing almost everything in the actual mingw32 folder.  The latter one has the cc1plus.exe that was being invoked, which lacked all the DLLs.  I consolidated the folders, and copied the required DLLs.

Now I'm back to this:

fatal error: Qt5Gui: No such file or directory
#include <Qt5Gui>

compilation terminated.

The same thing I was getting before ><  And I thought I had made progress.

I didn't want to implicitly blame Code::Blocks, but I'm all out of ideas and steam.  So, I'll repost with the format the wiki describes.
« Last Edit: September 22, 2013, 09:40:10 am by onesteplower »

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #7 on: September 22, 2013, 11:36:09 am »
Are you actually trying to compile Qt or use it? Using Qt with CB is possible but you'll also run into the 'QT_OBJECT' problem after you manage. It has a solution though.

Anyway my qt installations (self compiled 4.8.4 and the official 4.7.3 installer) both lack 'QtBase' and 'activeqtversion.h'. Can you pls direct me to the actual locations of these files so I may be of help.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Has anybody gotten Qt5 to work with Code::Blocks on Windows?
« Reply #8 on: September 24, 2013, 01:39:18 am »
Anyway my qt installations (self compiled 4.8.4 and the official 4.7.3 installer) both lack 'QtBase' and 'activeqtversion.h'. Can you pls direct me to the actual locations of these files so I may be of help.


In the two copies of 5.1.1 I installed the file activeqtversion.h in these paths.

Code
5.1.1\mingw48_32\include\ActiveQt

Code
5.1.1\msvc2010_opengl\include\ActiveQt

I found no file called "QtBase" in the two installations; I did find files like this one "qtbase_uk.qm" under this folder "translations".

Build command; it fails to run but it does compile and link. I am using "C:\Apps\Qt\Qt5.1.1msvc" as the base install folder location.
Code
cl.exe /nologo     /IC:\Apps\Qt\Qt5.1.1msvc\5.1.1\msvc2010_opengl\include /IC:\Apps\Qt\Qt5.1.1msvc\5.1.1\msvc2010_opengl\include\QtGui /IC:\Apps\Qt\Qt5.1.1msvc\5.1.1\msvc2010_opengl\include\QtWidgets /IC:\Apps\Qt\Qt5.1.1msvc\5.1.1\msvc2010_opengl\bin /I"C:\Program Files\Microsoft SDKs\Windows\v6.0A\include" /I"C:\Program Files\Microsoft Visual Studio 10.0\VC\include" /c main.cpp /Foobj\Release\main.obj
main.cpp
link.exe /nologo /LIBPATH:C:\Apps\Qt\Qt5.1.1msvc\5.1.1\msvc2010_opengl\lib /LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib" /LIBPATH:"C:\Program Files\Microsoft Visual Studio 10.0\VC\lib" /out:bin\Release\testqt5msvc.exe Qt5Core.lib Qt5Gui.lib Qt5Widgets.lib obj\Release\main.obj  
Output file is bin\Release\testqt5msvc.exe with size 32.50 KB

FYI: I wasted enough time on helping the OP out; so, I am back to doing other things in my free time.

Did you include the QtWidgets folder in the search path as I needed to do to get MinGW GCC to compile?

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Tim S.
Edit: added quote to the request.

The OP seems to be ignoring the post build log request of mine a few posts back without it it is nearly impossible to help, anyway.

Tim S.
« Last Edit: September 24, 2013, 02:17:17 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org