views:

1913

answers:

6

I'm having some trouble installing and configuring qt on my vista laptop.

I'm trying to setup a development environment on my laptop where I compile from the command line, because that's how the environment is setup on my university's linux machines, so I don't want to tie myself to some IDE .. (plus, real programmers use the command line!)

I haven't used the command line before for C++ development, it was all MSVC, so now I'm having a bit of trouble.

I'm still using MSVC, but from the command line. I practically have no idea what's going on, I just know that I have to run:

qmake
nmake

to compile my code!

I downloaded the opensource version of qt, and did the configuration, and tried a simple qt application (from a tutorial) and it worked, it compiled and executed pretty much as expected.

Now, when I decided to run another project that uses opengl, I got the following error:

fatal error C1083: Cannot open include file: 'qgl.h': No such file 
or directory

I'm not sure where does the compiler look for header files, and I didn't copy any header files anywhere, I assume that configure.exe worked its magic somehow and added the include directory to one or more enviroment variables or to some registery location or whatever other peculier places that the MSVC compiler searches for to find include directories.

However, what I did was search my C:\qt\include\ folder to make sure that qgl.h exists, and sure enough there it was. so why can't nmake find it?

A: 

Qmake generates Makefile from *.pro file located in current directory. It has qt path compiled in. Type "qmake -v" to see it. You can't move qt's dir after compiling it. If You haven't moved it, first maybe try to install Qt following instruction from INSTALL file. Good luck.

Jacek Ławrynowicz
+1  A: 

If you want to stay with the command line anyway (plus use it on a linux box later / parallel) I'd suggest at least trying out the MinGW version of Qt. I'm using it regularly, and besides of the non-existance of a GUI it works pretty well. Using MinGW also has the advantage that you can simply download and install the MinGW edition of Qt and don't need to reconfigure or recompile anything.

Also, trying out QtCreator might be interesting. It's still beta and requires the beta Qt 4.5 but it's a nice small IDE that integrates nicely with gcc.

bluebrother
hmm using mingw sounds like a good idea, I'll give it a try, thanks
hasen j
To nitpick, this doesn't answer the question, it just provides a workaround.
Max Howell
yea well, as long as it solves my problem,
hasen j
+1  A: 

Two potential solutions (they solved issues at my workplace)

Do you have qt include and bin folders in the PATH variable? I think the doc says only one of these is needed, but one of the students had Vista and putting the other in the PATH variable solved a "Cannot open include file" problem.

If you're using MSVC did you run configure and nmake from the Visual Studio command prompt? We had problems when using the bare windows Command Prompt because the VS one adds a lot of temporary environment variables to the configure process.

Good luck

Chris Cameron
yea I used the Visual Studio command prompt, I added the bin to PATH (that's pretty much a given) but I also had to add `lib` to PATH as well, (for dll's), now gonna try to add `include` too, man what a mess.
hasen j
A: 

The opensource version of Qt does not provide profiles (mkspecs in qt terms) so qmake can generate nmake (msvc) compatible makefiles.

You have to use mingw/gcc.

This is no longer true IIRC.
Max Howell
+2  A: 

I think the actual solution to this is in your pro file:

QT += opengl

Max Howell
Yea, this only solves the problem of the linker not finding the opengl staticlibrary, but it doesn't solve the header file problem, I switched to mingw and added opengl to CONFIG and it worked
hasen j
The Qt line modifies the INCLUDEPATH too, so it should work. But this stuff always has multiple factors at play.
Max Howell
but actually qgl.h was in the default include folder from the start (for me anyway), but it containted one line only #include ``"../QtOpengl/qgl.h"`` or something similar
hasen j
A: 

Install the complete Qt SDK for Windows which includes Qt 4.6 SDK, Qt Creator 1.3, and MinGW.

It will also install "Qt Command Prompt" launcher that you can use to build Qt apps from the command line.

I'm sure you're more familiar with MSVC than MinGW, as I do too (I've been using MSVC 6.0 to MSVC# 2008 for developing .NET apps).

But try MinGW with Qt and I think it's better for long term. I do some C++ development on Linux too so getting familiar with MinGW will be beneficial for you in cross-platform C++/Qt development.

For more info, see Installation of Qt 4.6 SDK for Windows.

Hendy Irawan