Qt cannot find the standard header - qt

The compilation is failing due to standard Qt include files/ library missing, why?
I have custom toolchain for devices. My compilation fails with messages:
In file included from /opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/QtCore/QString:1:0,
from ./menuitems/Item.h:5,
from ./appmessages/AppMessageAgeLimit.h:4,
from appmessages/AMessageDispatcher.cpp:2:
/opt/STM/STLinux-2.3/devkit/sh4/target/usr/include/QtCore/qstring.h:60:22: fatal error: string: No such file or directory
It guess that this toolchain has been configured wrong but I don't know how to fix it. Below is output from "/opt/STM/STLinux-2.3/devkit/sh4/bin/sh4-linux-g++ -v" command - may be it will be useful:
Using built-in specs.
COLLECT_GCC=/opt/STM/STLinux-2.3/devkit/sh4/bin/sh4-linux-g++
COLLECT_LTO_WRAPPER=/opt/STM/STLinux-2.3/devkit/sh4/libexec/gcc/sh4-linux/4.8.2/lto-wrapper
Target: sh4-linux
Configured with: /home/viatcheslavvgavrilov/qt/gcc-4.8.2/configure --target=sh4-linux --prefix=/opt/STM/STLinux-2.3/devkit/sh4 --exec-prefix=/opt/STM/STLinux-2.3/devkit/sh4 --bindir=/opt/STM/STLinux-2.3/devkit/sh4/bin --sbindir=/opt/STM/STLinux-2.3/devkit/sh4/sbin --sysconfdir=/opt/STM/STLinux-2.3/devkit/sh4/etc --datadir=/opt/STM/STLinux-2.3/devkit/sh4/share --includedir=/opt/STM/STLinux-2.3/devkit/sh4/include --libdir=/opt/STM/STLinux-2.3/devkit/sh4/lib --libexecdir=/opt/STM/STLinux-2.3/devkit/sh4/libexec --localstatedir=/opt/STM/STLinux-2.3/devkit/sh4/var --sharedstatedir=/opt/STM/STLinux-2.3/devkit/sh4/share --mandir=/opt/STM/STLinux-2.3/devkit/sh4/man --infodir=/opt/STM/STLinux-2.3/devkit/sh4/info --enable-checking=assert --program-prefix=sh4-linux- --with-local-prefix=/opt/STM/STLinux-2.3/devkit/sh4 --with-sysroot=/opt/STM/STLinux-2.3/devkit/sh4/target --enable-languages=c,c++ --enable-threads=posix --enable-nls --enable-c99 --enable-long-long --with-system-zlib --enable-shared --disable-libgomp --enable-multilib --with-multilib-list=m4,m4-nofpu --enable-symvers=gnu --with-gxx-include-dir=/target/usr/include/c++/4.2.4 --enable-__cxa_atexit
Thread model: posix
gcc version 4.8.2 20131016 (GCC)

The compilation is failing due to standard Qt include files/ library missing, why?
Checking on qt.conf file section Paths prefix usually helps:
[Paths]
Prefix=/some/path
With my several statically built Qt flavors it is usually set to one of:
[Paths]
Prefix=/specific_prebuilt_qt/src/qtbase
And the default prefix may point to one directory up which can be the valid case but then make sure the path to Qt tool-chain is correct. Or where's bin folder for the Qt you intend to use? The folder where qmake tool is.
[Paths]
Prefix=..
Make sure after the prefix path fixed qmake executed for your project before building again.

Related

Where does CMake look for modules? (trying to fix errors after environment changes)

I'm trying to build a QT5 application using CMake, and it builds fine under normal circumstances.
But I need to build it with the Linux AM335X toolchain / SDK, so I source the "environment-setup" script, which makes a large amount of changes to environment variables.
Now when I run CMake I get this error:
CMake Error at CMakeLists.txt:27 (find_package):
By not providing "FindQt5Quick.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Quick",
but CMake did not find one.
Could not find a package configuration file provided by "Qt5Quick" with any
of the following names:
Qt5QuickConfig.cmake
qt5quick-config.cmake
Add the installation prefix of "Qt5Quick" to CMAKE_PREFIX_PATH or set
"Qt5Quick_DIR" to a directory containing one of the above files. If
"Qt5Quick" provides a separate development package or SDK, be sure it has
been installed.
This is my CMakeLists.txt file.
project(SPRITER_PLUS_PLUS_QT)
cmake_minimum_required(VERSION 2.9)
option(COMPILE_QML_PLUGIN "Compile the qml plugin" ON)
if(${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
message(FATAL_ERROR "In-tree build attempt detected, aborting. Set your build dir outside your source dir, delete CMakeCache.txt from source root and try again.")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# Compiler options
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fmax-errors=2 -Wall -Wno-unused-function")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(SKIP_EXAMPLES ON)
include("QtCreatorResources")
#Qt
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
find_package(Qt5Quick REQUIRED) # this is the offending line.
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Multimedia REQUIRED)
add_subdirectory(spriterplusplus EXCLUDE_FROM_ALL)
add_subdirectory(qtdocumentwrapper EXCLUDE_FROM_ALL)
add_subdirectory(qt)
add_subdirectory(example)
qtcreator_add_project_resources(${SPRITER_ENGINE_SRCS} ${SPRITER_ENGINE_HDRS})
qtcreator_add_project_resources(${SPRITER_EXAMPLE_SRCS} ${SPRITER_EXAMPLE_HDRS})
My main question is how do I tell where it's looking for Qt5QuickConfig.cmake which exists in several locations on my machine? I have checked CMAKE_MODULE_PATH but it appears to be the same (just the location I'm running CMake from) whether I run successfully or within the toolkit environment.
Any other hints to fix this issue would be greatly appreciated.
Note: I've already done stuff like sudo apt-get install qtdeclarative5-dev which is why it works in the normal environment. I'm guessing in the SDK's environment, it no longer knows where that put it hence my question.

No rule to make target in QtCreator compilation on Windows with LLVM

I need to compile a cocos2dx project on Windows 10 which has some objective-c++ code, and all that using QtCreator. I've managed to set the compilers in the kit to LLVM (so that objective-c++ code can be compiled), as well as change the qmakespec to win32-clang-g++, however, I'm still getting this error when trying to compile:
error: No rule to make target 'C:/Qt/Qt5.12.9/5.12.9/msvc2017_64/lib/libQt5OpenGLd.a', needed by 'debug/libcocos2d.a'. Stop.
The folder in question contains file Qt5OpenGLd.lib, but doesn't have libQt5OpenGLd.a.
How do I fix this? I can provide more info, but I'm not sure what info is relevant.
I had to use win32-clnag-msvc in order to have it compile a .lib file instead of .a file.

Why does a build of a qmake project fail with 'qglobal.h': No such file or directory?

I'm trying to release-build a qmake-based, Qt-using project (Qt Creator) as follows, starting from a clean command prompt:
"%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
cd build
\qt\5.7.0-shared\bin\qmake.exe "CONFIG=release" \qt\qt-creator-opensource-src-4.1.0
nmake
Output:
[...]fatal error C1083: Cannot open include file: 'qglobal.h': No such file or directory
This is perfectly reproducible on every machine I've tried it on, across multiple Qt versions. The choice of a project doesn't matter: it could be a trivial one.
The CONFIG qmake variable holds a list of default values. One of those is QT. By assigning to it, the defaults are overriden. Thus QT is removed from the configuration, and the build does not to depend on Qt. Thus no Qt includes are found.
Instead, one must append the value to CONFIG:
qmake "CONFIG+=release" [...]

Error in OpenCV configuration for Qt Creator

I followed these instructions in the configuration of OpenCV SDK for using it in Qt Creator IDE, but I couldn't conclude point 6.5, due to configuration errors in Cmake-GUI. I setup the configuration in CMake of the compilers gcc and g++ contained in Qt folder for MinGW32, and all looks Ok. But when Cmake-GUI starts the process of build configuration it ends up saying
"Error in configuration process, project files may be invalid".
It can't find the following:
QT_QMAKE_EXECUTABLE;
Qt5Concurrent_DIR;
QT5Core_DIR;
QT5Gui_DIR;
QT5Test_DIR;
QT5Widgets_DIR.
After this issue I tried to go on with following points of configuration tutorial, without reaching the final instruction of mingw32-make install. I'm using the following versions of softwares: Qt 5.3.0, OpenCV 2.4.9, CMake 2.8.12.2. My OS is Windows 7.
How can I recover the missing Qt files in CMake configuration?
Is there an alternative way for configuring OpenCV with Qt (like using precompiled build of OpenCV libraries)?
You just need to indicate CMake the correct paths to each one. Click oh the path to browse and set each one individually:
QT_QMAKE_EXECUTABLE;
For this one, you need to search inside the Qt installation folder for the /bin directory. On it, you' ll find the qmake.exe. In my case it was C:/Qt/5.3/winrt_x64/bin/qmake.exe
All the following ones are in the Qt's /lib/cmake directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake :
Qt5Concurrent_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Concurrent
QT5Core_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Core
QT5Gui_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Gui
QT5Test_DIR;
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Test
QT5Widgets_DIR.
C:/Qt/5.3/winrt_x64/lib/cmake/Qt5Widgets
Then click generate. It' ll show a new error and ask you for the QT5OpenGL_DIR. Just as before, show CMake the correct directory. In my case: C:/Qt/5.3/winrt_x64/lib/cmake/Qt5OpenGL. Finally, click Configure again, and then Generate, and now you're done creating the build files.
You have to specify the location of Qt manually by passing it as an argument for QT5Core_DIR. Qt5_DIR or CMAKE_PREFIX_PATH does also the trick.
Example
Given your Qt 5 is installed at /opt/selfcompiled/Qt5. When calling cmake, add the flag from above:
cmake -DQt5_DIR=/opt/selfcompiled/Qt5 <pathToSourceDir>
Once the Qt 5 directory is set and found by CMake, all the other variables related to Qt 5 should be found from there, too.

Qt 4.5.2 - linux - change library root

I have 2 versions of Qt for different arm devices and different toolchains: Qt 4.5.2 and Qt 4.7.3. Both versions are supposed to be placed in /opt/onyx/arm directory :(
The following error is occurred if I move the 1st Qt build in another directory (/usr/arm-marvell-linux-gnueabi) and run qmake:
#!/bin/sh
export QTDIR=/usr/arm-marvell-linux-gnueabi
/usr/arm-marvell-linux-gnueabi/bin/qmake -o Makefile.qt.onyx.a6x -spec qws/arm-marvell-linux-gnueabi-g++ project.pro
./run_qmake1.sh
Could not find mkspecs for your QMAKESPEC(qws/arm-marvell-linux-gnueabi-g++) after trying:
/opt/onyx/arm/mkspecs
Error processing project file: project.pro
What could be the issue and how can I resolve the /opt/onyx/arm conflict?
I would recommend grepping through /usr/arm-marvell-linux-gnueabi for any references to /opt/onyx. If you can't successfully change them (because they're in a binary), you could use symlinks to switch toolchains as needed.

Resources