[CMake] CMake is unable to find QtCore!

Andreas Pakulat apaku at gmx.de
Mon Aug 13 16:44:58 EDT 2012


Hi,

On Mon, Aug 13, 2012 at 9:40 PM, Toronto Andrew
<andrew.louis93 at gmail.com> wrote:
>
> Andreas Pakulat-2 wrote
>>
>> Relocating Qt requires either patching the qmake binary or installing
>> a qt.conf file to help qmake find the libs in the new position. The
>> absolute include/lib dirs are hardcoded into qmake when its being
>> built. See http://doc.qt.nokia.com/4.7/qt-conf.html for the
>> file-format
>>
>> -> *First off, I really appreciate you looking at my build errors.
>>
>> Patching the qmake binary? I reinstalled the 4.8.2 binary, why is this not
>> enough?

Well, patching the qmake binary is exactly what happens when you use
Nokia's binary installer for Qt and it patches qmake to the install
location you chose during the installation. The patching/qt.conf file
is only necessary if you then move Qt again to another location.

>>> FindQt4 now actually finds 4.8.2 as opposed to 4.8.0, however
>>> some flags like QT_USE_FILE and QT_QTGUI_LIBRARY seem to still point at
>>> 4.8.0 prompting some linker issues during the build.
>>
>> Does that mean you didn't move Qt this time?
>>
>> -> *Well, I have both Qt versions withing the same directory (C:/Qt/4.8.0
>> as well as C:/Qt/4.8.2), and while qmake seems to be configured properly
>> for 4.8.2, I feel like it is the flags I mentioned earlier that point at
>> 4.8.0, however, I could be mistaken.

You can actually find out how cmake gets qt libs etc. from qmake:

qmake -query

produces a list of paths. CMake will use these with
find_library/find_file and prefers them over the standard lookup paths
of those functions (by using them as HINTS). So if qmake produced
QT_INSTALL_LIBS:C:\Qt\4.8.2 then CMake should find all Qt libraries in
that location.

>>> Just for reference, the CMakeLists is found  http://pastie.org/4466367
>>> here
>>> if need be.
>>
>> Did you start with a clean cache? The screenshot suggests you're
>> trying to mix debug and release Qt libraries, thats a very bad idea
>> anyways (QtOpenGLdd and QtGui4 are mentioned). So maybe things are
>> still not picked up as you think they are? The cache-file should have
>> more information.
>>
>> And you should get rid of LINK_DIRECTORIES, thats not a good idea and
>> almost always the wrong fix to whatever linking problems you have.
>> CMake find-modules are supposed to setup the absolute path to
>> libraries in the variables they 'export', which can be used with
>> target_link_libraries directly. Same goes for the 'link_libraries'
>> call for MacOSX I'd say.
>>
>> Andreas
>>
>> *I did start with a clean cache. I see what is happening with the
>> debug/release libraries, but do you know what might have caused this?

Not without seeing the cmake cache or some output what the various
cmake variables you're using actually contain.

>> There is nothing in the CMakeLists file that seems like it may be causing
>> it. Could it be a way the other libraries are built (VTK ?)

Could be, if the other cmake variables contain Qt debug libs, since
you use them with link_directories and link_libraries they could
influence the sample-target.

Andreas


More information about the CMake mailing list