As in the above im trying to compile a QT5 project inside of QT Creator with cmake and want to add the antlr package.
Infos: Qt 5.12.8, Antlr 4.8, Compilers tried: mingw gcc|g++ , msvc 2015,2017
System: Windows / Linux both do not work
For including Antlr 4.8 i use the provided CPP Package to build Antlr from Source
This is the project i am working on.
https://github.com/MrDiver/ArmSimulator/tree/ArmParser/src/asmeditor/AsmEditor
i include antlr4 with the following https://github.com/MrDiver/ArmSimulator/blob/ArmParser/src/asmeditor/AsmEditor/CMakeLists.txt#L14-L21
and normally it works perfectly fine when i compile something with it. But this time when i try to include the header files for antlr i get this error message
FAILED: CMakeFiles/AsmEditor.dir/managers/processormanager.cpp.obj
H:\Programme\QT\Tools\mingw730_64\bin\g++.exe -DANTLR4CPP_STATIC -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I. -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor -IAsmEditor_autogen/include -Iantlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/armparser/assembler -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/armparser/walker -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/codearea -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/managers -IH:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/armparser -isystem H:/Programme/QT/5.12.8/mingw73_64/include -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtWidgets -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtGui -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtANGLE -isystem H:/Programme/QT/5.12.8/mingw73_64/include/QtCore -isystem H:/Programme/QT/5.12.8/mingw73_64/./mkspecs/win32-g++ -O3 -DNDEBUG -std=gnu++11 -MD -MT CMakeFiles/AsmEditor.dir/managers/processormanager.cpp.obj -MF CMakeFiles\AsmEditor.dir\managers\processormanager.cpp.obj.d -o CMakeFiles/AsmEditor.dir/managers/processormanager.cpp.obj -c H:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/managers/processormanager.cpp
In file included from antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/antlr4-runtime.h:31:0,
from H:/MyStuff/PrivateProjects/CPPProjects/ArmSimulator/src/asmeditor/AsmEditor/managers/processormanager.cpp:2:
antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/Lexer.h:116:46: error: invalid declarator before 'newToken'
virtual void emit(std::unique_ptr<Token> newToken);
^~~~~~~~
antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/Lexer.h:116:46: error: expected ')' before 'newToken'
antlr4_runtime/src/antlr4_runtime/runtime/Cpp/runtime/src/Lexer.h:123:25: error: expected unqualified-id before ')' token
virtual Token* emit();
^
[30/31 0.6/sec] Building CXX object CMakeFiles/AsmEditor.dir/armparser/assembler/ARMParser.cpp.obj
ninja: build stopped: subcommand failed.
18:59:55: The process "C:\msys64\mingw64\bin\cmake.exe" exited with code 1.
Error while building/deploying project AsmEditor (kit: Desktop Qt 5.12.8 MinGW 64-bit)
When executing step "CMake Build"
File of Interest: https://github.com/MrDiver/ArmSimulator/blob/ArmParser/src/asmeditor/AsmEditor/managers/processormanager.cpp
Seems pretty much like it can't find std::unique_ptr<Token> but i can't change a lot about this, because these are the antlr sources and they actually work.
So i don't really know anymore where to search for the problem. The library itself compiles fine if i choose it as target in the settings.
What i tried:
Compiling the antlr library outside and just linking it in the cmake file.
Changing the Lexer.h file with #include <memory>.
Compiling the QT project without QT Creator (Resulting in a ton more errors because i cant get the linking for QT to work)
Compiling every Antlr related file outside of the project (Works perfectly fine without QT but not really what i need)
Using different compilers and different Systems.
Searching for a problem with moc but it doesn't seem to influence it. But i doubt i looked hard enough on moc for this.
And im quite new to QT so i don't know everything what the Qt Creator does behind the scenes. It seems like too much if i can't compile it with plain cmake out of the box.
Thanks for the help in advance.
The problem is that Antlr has methods like "emit" that conflict with the Qt reserved word "emit". The solution is to disable the flag "no_keywords" (in qmake add CONFIG += no_keywords, and in CMake add add_definitions(-DQT_NO_KEYWORDS)) as indicated by the docs. Then you must make the following conversions:
emit to Q_EMIT
slot to Q_SLOT
slots to Q_SLOTS
signal to Q_SIGNAL
signals to Q_SIGNALS
Related
I have recently updated gcc and g++ to version 7.2. I would like to try out std::experimental::any and std::variant in particular, and I am using Qt 5.9.1 in QtCreator.
So far I have written this in the project file:
CONFIG += c++17
And I have added the correct headers in the correct places:
#include <variant>
#include <experimental/any>
Any works fine, no problems there. However, when I include the variant header file, I get this error:
/usr/include/c++/7/bits/c++17_warning.h:32: error: #error This file requires compiler and library support for the ISO C++ 2017 standard. This support must be enabled with the -std=c++17 or -std=gnu++17 compiler options.
#error This file requires compiler and library support \
^~~~~
I have tried a variety of things in the project file, here is the full list:
CONFIG += c++17
&
CONFIG += c++1z
&
QMAKE_CXXFLAGS += -std=c++17
&
QMAKE_CXXFLAGS += -std=c++1z
&
CONFIG += c++17
QMAKE_CXXFLAGS += -std=c++17
&
CONFIG += c++1z
QMAKE_CXXFLAGS += -std=c++1z
&
CONFIG += c++11
CONFIG += c++14
CONFIG += c++17
That's every stab in the dark I could think of. What am I missing? And why does experimental::any compile when variant doesn't?
I know I shouldn't use CONFIG += c++xx and QMAKE_CXXFLAGS together in this way, but I thought I'd give it a go as nothing else works. For bonus points, I'm also wondering, should I add the CONFIG calls for 14 and 11 when I already CONFIG for 17?
EDIT:
Here is the compiler output with most of my filenames scrubbed out:
18:04:10: Running steps for project AIQt...
18:04:10: Configuration unchanged, skipping qmake step.
18:04:10: Starting: "/usr/bin/make"
/home/pete/Qt/5.9.1/gcc_64/bin/qmake -o Makefile ../AIQt/AIQt.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
WARNING: Failure to find: ../src/stdafx.h
WARNING: Failure to find: ../src/Csound/csd.h
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_DATAVISUALIZATION_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../AIQt -I. -I../src -I../src/AIBase -I../src/Maths -I../src/Random -isystem /usr/local/include/csound -I../../../../Qt/5.9.1/gcc_64/include -I../../../../Qt/5.9.1/gcc_64/include/QtDataVisualization -I../../../../Qt/5.9.1/gcc_64/include/QtWidgets -I../../../../Qt/5.9.1/gcc_64/include/QtGui -I../../../../Qt/5.9.1/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I../../../../Qt/5.9.1/gcc_64/mkspecs/linux-g++ -o main.o ../AIQt/main.cpp
In file included from /usr/include/c++/7/variant:35:0,
from ..###,
from ..###,
from ..###,
from ..###,
from ..###,
from ..###,
from ..###,
from ..###:
/usr/include/c++/7/bits/c++17_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2017 standard. This support must be enabled with the -std=c++17 or -std=gnu++17 compiler options.
#error This file requires compiler and library support \
^~~~~
In file included from ..###,
from ..###
from ..###,
from ..###,
from ..###,
from ..###,
from ..###:
../src/AIBase/Geno.h:70:18: error: ‘variant’ in namespace ‘std’ does not name a type
std::variant m_valueVariant;
^~~~~~~
In file included from ..###,
from ..###,
from ..###,
from ..###,
from ..###,
from ..###:
../src/AIBase/Pheno.h:22:13: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
const double getGenoValue(size_t genoIndex) const;
^~~~~
../src/AIBase/Pheno.h:24:13: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
const UserRating getRating() const;
^~~~~
In file included from ..###,
from ..###:
../AIRadioQt/GraphDialog.h:16:15: warning: declaration ‘struct ar::ai::ClusterList’ does not declare anything
class ar::ai::ClusterList;
^~~~~~~~~~~
make: *** [main.o] Error 1
18:04:13: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project AIQt (kit: Qt 5.9.1 GCC 64bit)
The kit Qt 5.9.1 GCC 64bit has configuration issues which might be the root cause for this problem.
When executing step "Make"
18:04:13: Elapsed time: 00:03.
ANSWER:
As mentioned by nwp, I just had to clean it and rebuild.
Another poster also commented that CONFIG += c++17 doesn't appear to be supported yet, so it is necessary to use QMAKE_CXXFLAGS += -std=c++17. He quickly deleted his comment though, so I am unable to thank him personally for going to the effort of checking the docs for me.
CONFIG += c++17 can be used with Qt 5.12 and later.
For Qt 5.11 and earlier, it is not a recognized QMake flag and you have to get your hands a bit dirty.
Adding QMAKE_CXXFLAGS += -std=c++17 does the job for GCC & Clang; for MSVC you will probably need to specify /std:c++17 or /std:c++latest.
Edit 3/2019: You can use CONFIG += c++17 since Qt 5.12.
The actual flag is c++1z, not c++17. In short, to get C++17 support, you don't need to modify QMAKE_CXXFLAGS and can instead simply use CONFIG += c++1z.
Discussion on the reason why can be found in this bug report, but it pretty much amounts to "we implemented it as c++1z before C++17 was standardized, and now we won't bother aliasing it."
Note: I realize you just needed a clean and rebuild. I'm answering the underlying question of "what flags do I need to use to enable C++17 support?"
By Example C++17 C++20 Builds with Qt5 version 5.15.3 (and above) on Linux (or similar on Windows)
Summary:
Inside CMakeLists.txt file for an application written in C++17 and using Qt
cmake_minimum_required(VERSION 3.16.0)
project(helloworld VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
A qt project configuration eg mygame.pro may have c++1z for C++17 or c++2a for C++20 or c++11 for older projects:
CONFIG += c++1z
On the command line of configure eg a C++20 project config, always use a shadow build:
../configure -c++std c++2a
cmake --build .. --parallel
Windows or Linux compiler command arguments examples with or without qt; at time of writing C++20 is c++2a and C++17 is c++1z others to follow.
$ g++ -std=c++2a hello_linux_is_the_worlds_device_future.cpp
c:\hello> cl /std=c++1z /EHsc hello_windows_is_in_decline.cpp
On windows notice the forward /slash.
More Detail:
I have found that building a new C++ project or even building ALL of qt5 open source thus creating my own qt release (which is tough) is possible by C++17 or C++20 (Qt6 requires at least C++17). I cloned and then checked out version qt5 5.15 i.e. ALL of qt5 open source and built it using C++20 - the build takes 23GB ... you don't need to do all that.
Note the config examples below, ... 4 hours of build on a fast PC are super fussy and I managed eventually. Anyway the point is that Qt5.15 was happy to build itself with the C++17 or C++20 settings (in my case using gcc g++-8 or g++-9) by example:
Just take a look at this cmake Get Started (qt6 C++17 example) but 20 works just as well)
Qt5 open source code total build of qt5.15.3 with C++20 configure example:-
mkdir qt5-build
cd qt5-build
../configure -release -opensource -nomake examples -nomake tests
-skip qtdocgallery -c++std c++2a -confirm-license -opengl desktop
-platform linux-g++-64 # put this all on one-line please.
cmake --build .. --parallel
OR use make -j4 as I did.
Considerable care was taken to write this for my own notes which I share, I am happy to make corrections myself and suggestions are welcome; never ever hack into an authors work and change it! Just as I do not go into a public library and remove pages from books. Examples count more than non-solutions, however examples age faster!
For Windows:
I'm download qt-opensource-windows-x86-5.11.1, icncluded MinGW32.
For MinGW64 I'm download qt-5.5.0-x64-mingw510r0-seh-rev0 and install only compiler.
Configure QtCreator, as says here.
Create new project and add QMAKE_CXXFLAGS += -std=gnu++1z to .pro file (gcc doc).
For test, try compile this simple code:
#include <optional>
std::optional<int> foo()
{
return std::nullopt;
}
int main(int argc, char *argv[])
{
foo();
}
I am using Qt 5.6 with Qt Creator 4.3 on macOS Sierra 10.12.
I am building a Qt based application that uses OpenGL and OpenCL.
Software or system updates somewhere appear to have broken Qt Creators' ability to find the headers for OpenGL and OpenCL headers.
I have tried reinstalling Qt, Reinstalling Xcode and the Mac SDK and none of these options make it work.
The weird thing is my app compiles. QtCreator just cannot find the headers itself - this makes code navigation somewhat more complex.
So lets take OpenCL. I include it like this:
#ifdef __APPLE__
#include <OpenCL/cl.h>
#include <OpenCL/opencl.h>
#endif
My app.pro file for qmake has the following inside it:
macx:QMAKE_LFLAGS += -framework OpenCL
And with this it seems to compile. However the two OpenCL #include above in QtCreator are yellow underlined with a tooltip saying "OpenCL/cl.h: No such file or directory".
Now I can see that it compiles successfully as qmake is working out where the frameworks are and appending the paths successfully:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/me/Projects/app -I. -I/Users/me/Qt5.6.2/5.6/clang_64/lib/QtWidgets.framework/Headers -I/Users/me/Qt5.6.2/5.6/clang_64/lib/QtGui.framework/Headers -I/Users/me/Qt5.6.2/5.6/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/Users/me/Qt5.6.2/5.6/clang_64/mkspecs/macx-clang -F/Users/me/Qt5.6.2/5.6/clang_64/lib -o main.o /Users/me/Projects/app/main.cpp
Now if I navigate to the following directory the headers are there and present:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A
So I cannot see what is missing.
I have tried to "teach" Qt Creator about this framework directory with combinations of the following, but I havent found something that will work:
macx:QMAKE_LFLAGS += -framework OpenCL
macx:INCLUDEPATH += /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers
macx:QMAKE_LFLAGS += -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
macx:LIBS += -framework OpenCL
I'm struggling to find information about how QtCreator find the system frameworks on a mac and how i get it to start finding them again. Any help would be massively appreciated.
For anybody that has the same problem the answer was actually rather simple in the end.
When you setup the kit in Qt creator (which tells it what compiler and debugger to use amongst other things) you need to be careful with the compiler used. I had two copies of clang on my machine, one was installed in /usr/bin (the system one) and the other was installed inside the XCode app bundle. My kit was using the Xcode installed one as thats where the libraries live. While this compiled just fine, Qt creator for some reason does not hook up the paths to libraries properly. Simply switching this over to using the one in /usr/bin solved it.
Note that i did not explicitly ask it to use the one in the Xcode app bundle, thats just the one that was automatically selected when the project was first opened in Qt creator. So you might have to adjust its default behaviour in order to fix things.
I’m trying to extend an existing makefile C++ project with a Qt GUI (Qt 5.6.0 because I cannot rely on Cxx11 features). The problem is I can’t get Qt to link properly. I’d like to build a X86 application (32bit) under Win7 (x86-64). I’ve installed qt-opensource-windows-x86-mingw492-5.6.0.exe obtained from the Qt download page https://download.qt.io/archive/qt/5.6/5.6.0/. Everything compiles. However, linking yields the following error:
C:/sofit/inuit_workspace/inuit_development/tools/makefiles/inuit/MakefileCatenaISS.mk:145:
recipe for target 'build/model/model.exe' failed
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:175:
undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:176:
undefined reference to
`_imp___ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:180:
undefined reference to `_imp___ZN7QWidget4showEv'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:181:
undefined reference to `_imp___ZN12QApplication4execEv'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:307:
undefined reference to `_imp___ZN12QApplicationD1Ev'
C:/sofit/inuit_workspace/inuit_development/tools/inuit/inuit.cpp:307:
undefined reference to `_imp___ZN12QApplicationD1Ev'
collect2.exe: error: ld returned 1 exit status
make: *** [build/model/model.exe] Error 1
I use the following command to link:
C:\Qt\Qt5.6.0\Tools\mingw492_32\bin\g++.exe -g
-LC:\Qt\Qt5.6.0\5.6\mingw49_32\lib -lQt5Widgets -lQt5Core -lQt5Gui -lQt5Cored -lQt5Guid -lQt5Widgetsd -lqtmain -lqtmaind -o build/model/model.exe ./build/model/objects/a.obj ./build/model/objects/b.obj
I’ve added a bunch of libraries and various combinations. Solely using Widgets, Core, and Gui doesn’t do the trick either.
Potential causes identified in answers in related questions (see below) aimed at
- Mismatch architecture lib/compiler
- Missing -lQt5Widgets
However, I don’t think this applies here. Please note that I’m not using CMake or QMake (hence no .pro file or CMake files) – just plain Gnu make called within Eclipse Mars.
The source (in case of interest):
int main(int argc, char *argv[])
QApplication app(argc, argv);
QWidget *widget = new QWidget;
Ui_MainWindow ui;
widget->show();
return app.exec();
}
And the compiler command (in case of interest):
C:\Qt\Qt5.6.0\Tools\mingw492_32\bin\g++.exe -IC:\Qt\Qt5.6.0\5.6\mingw49_32\include -IC:/my_project -Wall -g -c -DWIN32 -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT C:/my_project/1.cpp -o C:/my_project/build/model/objects/1.obj
I've tried it with/without the Qt symbols.
Does anyone know what might be the problem?
Related:
Compiling Qt5 hello world .cpp file under Windows using MinGW-w64 gives "undefined reference" error
C++ Qt: undefined reference to `_imp___ZN12QApplicationC1ERiPPci'
Compiling Qt5 hello world .cpp file under Windows using MinGW-w64 gives "undefined reference" error
http://www.qtcentre.org/archive/index.php/t-34997.html
Qt5 linking error
Any help is highly appreciated.
There is precisely one way to get it to work without wasting a lot of time:
Use qmake to generate a Makefile for your project.
Ensure that it builds.
Clean up the Makefile according to your needs, if desired.
You're of course free to keep regenerating the Makefile using qmake whenever you alter your sources. The major thing you'll find out is that maintaining makefiles manually is a royal pain, since you also need to maintain the dependency lists and that requires recursively scanning the files included by each translation unit. In other words, whatever Makefiles you come up with yourself will not properly rebuild the project as you modify it. Thus you'll be abandoning the benefits of the Makefile during the development process. Most manually-generated Makefiles are sorely lacking the proper dependencies of each source file - because nobody sane will manually maintain it, and once you're maintaining it automatically, you might as well use qmake or cmake to do the job.
Finally, there's no such thing as Qt that doesn't have qmake, so not using qmake is silly. If you depend on Qt, you're not making anything any easier by pretending that qmake isn't there: your project will use many other binary tools that Qt provides anyway, so giving qmake a special status just wastes your time. If your project is going to be big, you'll save lots of build time by using cmake with the Ninja generator instead, as qmake is currently stuck generating recursive Makefiles, and those lead to poor build performance.
Questions:
My question is thus: How do I build my QT project without turning off warnings altogether (or having to sort through a million purposeless ones to find my own)? Can I suppress warnings for just the QT headers?
Details:
Issue
A number of months ago, I started a QT project in QT-Creator. At the time I was using gcc 4.6. After a bit other priorities asserted themselves and I found myself without time to work on the project until now. In the interim I switched to using clang. When I configured my QT project to use clang -- which project compiled without warnings in g++ -- it generated some 263 warnings all within the QT headers themselves. Mostly sign-conversion and unreachable-code.
Attempts
To try and get around this I added -isystem /path/to/QT/include/dir based on this entry in the Clang User Manual, but it did not seem to affect anything. Though I am not certain, I think it is because my code #include's the QT headers by name, not by directory. While the solution to that might be to manually list every single QT header used (have not tried), it would mean I would have to update it every time I upgraded QT or used a new header. Surely there is a better solution.
As requested here is the actual compile command being executed:
clang++ -c -pipe -Qunused-arguments -Weverything -cxx-isystem /path/to/qt/4.8.3/include/ -g -D_REENTRANT -DQT_NO_KEYWORDS -DQT_SHARED -I/path/to/qt/x86_64/4.8.3/mkspecs/unsupported/linux-clang -I. -I.moc -I.ui -I/path/to/qt/4.8.3/include/ -o .obj/main.o main.cpp
Specs
I am using:
Linux 3.2.0-40-generic #64-Ubuntu SMP x86_64 GNU/Linux
Though others on my team use Windows
QT creator 2.6.2
QT 4.8.3
clang version 3.2 (trunk 165250) (llvm/trunk 165249)
Target: x86_64-unknown-linux-gnu
I will answer my own question because, as it turns out, it is a specific environmental quirk in this case.
I have two copies of the QT libraries on my dev machine, one system-wide and one project specific (included in the VCS). The project libraries do not have qmake included, so I used my system qmake, which appended a different path than I was including in my -isystem specifications. To solve this, I added
QMAKE_INCDIR_QT =
to qmake.conf (in qt/mkspecs/unsupported/linux-clang/)
Since someone else on the project had fanangled qmake into using the project libraries everywhere else.
For those who stumble upon this question with a more general problem than the author.
Try inserting:
LIBS_USED_FOR_QT = QtCore QtSql QtMultimediaWidgets QtSensors QtSvg QtXml QtPrintSupport QtWidgets QtQuick QtQml QtPositioning QtGui QtWebKitWidgets
for(somelib, $$list($$LIBS_USED_FOR_QT)) {
QMAKE_CXXFLAGS += -isystem $$(QTDIR)/lib/$${somelib}.framework/Versions/5/Headers/
QMAKE_CXXFLAGS += -isystem $$(QTDIR)/lib/$${somelib}.framework/Headers/
}
in your .pro file.
Addtionally avoid includes like #include <QtCore/QtCore>
writing #include <QtCore> instead
This tamed qt quite efficiently for me.
see also this source
i want to get started with QT. I donwloaded QT5 MINGW compiler with QT creator and i am trying to build the pre attached example named affine the problem is that the QT5 i think embed the project name with each of source file and thus gives error that file not found. some thing similar
:-1: error: ..affinemain.cpp: No such file or directory
while the file name is just
main.cpp
i don't know how to fix it. I searched lot on internet but could not found anything useful.
I even try to compile from command prompt but i am not fimmiliar with command prompt compiling as i am new to QT and previously i am totally developed with IDE in visual studio and eclipse for java so i have no idea about the make file and compiler command line arguments.
could some body please help me to fix this issue and can you tell please why compiler attaching project name with the source file name?
Thanks in advance
I have got the same problem and my solution may help you.
I am working with Qt5.0.1 now, and there are two distributions to work on windows with it: Qt5.0.1-mingw and Qt5.0.1-msvc2010.
I had to use mingw and there was a problem on my setup that "/" is ignored in path's.
So according to Qt Creator, compiler was called to process file mainwindow.cpp and this file was passed to it
g++ /*truncated*/ ..\qt-example\mainwindow.cpp
Below is the full compiler input:
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I..\qt-example -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtCore" -I"debug" -I"." -I"." -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspecs\win32-g++" -o debug\mainwindow.o ..\qt-example\mainwindow.cpp
And the error produced.
g++.exe: error: ..qt-examplemainwindow.cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
So, we can see that "\" is ignored by the compiler and file name is merged with directory name.
The solution to that problem goes to the tools that are used - MinGW (Minimalist ports of GCC and Binutils). And also MSYS - a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. In our case - g++.
MSYS is not shipped with Qt5.0.1-mingw and g++ is not using it, but having MSYS available in your PATH environment variable breaks the system.
MSYS is used for git scm, which I have installed, so my path contains links to MSYS that goes bundled with git. So I have next paths in my PATH environment variable.
C:\Program Files (x86)\git\bin;C:\Program Files (x86)\git\cmd
I have not found how MSYS is used by Qt Creator or g++, or where it is linked, but when I have dropped next path from PATH:
C:\Program Files (x86)\git\bin;
and restarted Qt Creator - g++ succeeded on compiling my file, it worked.
The question why/how it influences the Qt Creator/g++ that should not use MSYS utils installed with git is still open.
i can´t comment.
important : delete all the files in the release and debug folder (compiled version) before try the tips of the autor ...