I have no idea why this is happening. But everytime I compile my application with a couple of the Qt versions that I have installed I now get these warnings:
In file included from /home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qbrush.h:50,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qpalette.h:46,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtWidgets/qwidget.h:48,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtWidgets/qdesktopwidget.h:44,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtWidgets/QDesktopWidget:1,
from ../src/../../CommonClasses/SQLConn/../../CommonClasses/common.h:6,
from ../src/../../CommonClasses/SQLConn/dbinterface.h:10,
from ../src/../../EyeExperimenter/src/sslclient/sslclient.h:10,
from ../src/../../EyeExperimenter/src/sslclient/ssldbclient.h:4,
from ../src/sslwrapper.h:6,
from ../src/main.cpp:3:
/home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qtransform.h: In member function ‘QTransform& QTransform::operator=(QTransform&&)’:
/home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qtransform.h:81:46: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘class QTransform’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
{ memcpy(this, &other, sizeof(QTransform)); return *this; }
^
/home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qtransform.h:57:20: note: ‘class QTransform’ declared here
class Q_GUI_EXPORT QTransform
Can any one tell me what this warning is and, more importantly, how do I get rid of it? From what I've seen it has to do with gcc8 which my system currently has, however I've tried chaging the compiler in the Qt Kits configuration of QtCreator and the warning still appears...
You use qmake as the build system generator, and then gnu make to actually build stuff - Qt Creator is just a shortcut from typing it all out on the command line :)
You can pass the relevant flag to the compiler by adding the following to your .pro file, then re-running qmake on the project (e.g. delete the build folder and build again):
QMAKE_CFLAGS_WARN_ON += -Wno-class-memaccess
QMAKE_CXXFLAGS_WARN_ON += -Wno-class-memaccess
QMAKE_CFLAGS += -Wno-class-memaccess
QMAKE_CXXFLAGS += -Wno-class-memaccess
Related
I'm trying to build a sample project using Qt 5.7 over Linux. Previously, the same project have been built with Qt 5.4.2 without issues. When I try with Qt 5.7, I get the followings errors:
undefined reference to `QJsonValue::toString() const'
I have tried installing Qt5.7 with Qt Maintenance Tool and also download from Qt official site and install it using .run file. When I run a locate to qjsonvalue I get the followings results:
$ locate qjsonvalue
/opt/Qt/5.4/Src/qtbase/include/QtCore/qjsonvalue.h
/opt/Qt/5.4/Src/qtbase/src/corelib/json/qjsonvalue.cpp
/opt/Qt/5.4/Src/qtbase/src/corelib/json/qjsonvalue.h
/opt/Qt/5.4/android_armv7/include/QtCore/qjsonvalue.h
/opt/Qt/5.4/android_x86/include/QtCore/qjsonvalue.h
/opt/Qt/5.4/gcc_64/include/QtCore/qjsonvalue.h
/usr/include/qt5/QtCore/qjsonvalue.h
/usr/share/doc/qt5/qtcore/qjsonvalue-members.html
/usr/share/doc/qt5/qtcore/qjsonvalue.html
According with the previous results, seems that I need to install something becuase qjsonvalue.h/cpp is not in my Qt5.7 core. Any ideas about how to solve it? Need to install anything else? As note, when I start Qt Maintenance Tool I get an alert message that says the following:
Your installation seems to be corrupted. Please consider re-installing from scratch.
Found this comming here via google. I had the same issue.
The API changed from a default argument
QString QJsonValue::toString(const QString & defaultValue = QString()) const
to two overloads.
QString QJsonValue::toString() const
QString QJsonValue::toString(const QString &defaultValue) const
You should build with the headers of the oldest version you want to support. But if you just need this one error fixed you can just change the call from
QJsonValue someval;
QString str = someval.toString();
to
QString str = someval.toString(QString());
But you will probably get some other linker error in the wake of fixing this one.
I am creating a Webots project on OSX, where I am including the following:
#include <core/MainApplication.hpp>
I get error
In file included from
/Applications/Webots/resources/projects/default/libraries/qt_utils/core/MainApplication.hpp:17:
/Applications/Webots/webots.app/Contents/Frameworks/QtWidgets.framework/Headers/QApplication:1:10:
fatal error: 'qapplication.h' file not found
include "qapplication.h"
1 error generated.
All contnet of /Applications/Webots/webots.app/Contents/Frameworks/QtWidgets.framework/Headers/QApplication:
#include "qapplication.h"
QApplication file content is too short. Also it seems like I cannot find qapplication.h on the file system, is that normal?
Would it be more sensible to use local installation of Qt framework than the one that comes with Webots? How do I change the .pro file then to link to local installation of Qt rather than to /Applications/Webots/resources/projects/default/libraries/qt_utils
My make file:
CXX_SOURCES = entry_points.cpp
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
USE_C_API = true
QT_UTILS = /Applications/Webots/resources/projects/default/libraries/qt_utils
INCLUDE = -I"$(QT_UTILS)"
LIBRARIES = -L"$(QT_UTILS)" -lqt_utils
space :=
space +=
WEBOTS_HOME_PATH=$(subst $(space),\ ,$(strip $(subst \,/,$(WEBOTS_HOME))))
include /Applications/Webots/resources/Makefile.include
EDIT:
I have discovered that when I try to run make in the folder: /Applications/Webots/resources/projects/default/libraries/qt_utils
I get many errors (among many others), such as:
/Applications/Webots/webots.app/Contents/Frameworks/QtWidgets.framework/Headers/QWidget:1:10:
fatal error: 'qwidget.h' file not found
include "qwidget.h"
...
/Applications/Webots/webots.app/Contents/Frameworks/QtCore.framework/Headers/QObject:1:10:
fatal error: 'qobject.h' file not found
include "qobject.h"
...
/Applications/Webots/webots.app/Contents/Frameworks/QtWidgets.framework/Headers/QApplication:1:10:
fatal error: 'qapplication.h' file not found
include "qapplication.h"
In facts, these files are indeed missing from the Webots qt_utils
This is probably because of this line:
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
Indeed, QT_MAJOR_VERSION and greaterThan are not a part of the Webots Makefile system. If the Qt widgets module is not present, then the qapplication.h cannot be found (because it is precisely defined in the widgets module). As Webots is using Qt 5 since a while, I would recommend you to simply define the Qt modules like this:
QT = core gui widgets
I am new to Frama-C. I would like to run it under Windows enviroments. My compiler is gcc,mingw.
I have tryied to run same examples from Value Analysis tutorial by I have a problem with library header files.
I've found that it's not possible to run frama-c because restrict keyword. It shows error in string.h file
void * __cdecl memcpy(void * __restrict__ _Dst,const void * __restrict__ _Src,size_t _Size) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
When I manually add #define restrict to all *.c files in SkeinProject
schneier.com/code/skein_NIST_CD_102610.zip
everything works correcly. By doing it by hand is not what I'm looking for.
Next step was to add argument -D__restrict__
frama-c -cpp-extra-args=-D__restrict__ -main=Init -val SHA3api_ref.c
[kernel] preprocessing with "gcc -C -E -I. -D__restrict__ SHA3api_ref.c"
../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/string.h:41:[kernel] user error: syntax error
[kernel] user error: skipping file "SHA3api_ref.c" that has errors.
[kernel] Frama-C aborted because of an invalid user input.
I've also generated precompiled *.i files but error still the same.
gcc -E -D__restrict__ SHA3api_ref.c >SHA3api_ref.i
frama-c -main=Init -val SHA3api_ref.i
../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include/string.h:41:[kernel] user error: syntax error
[kernel] user error: skipping file "SHA3api_ref.i" that has errors.
[kernel] Frama-C aborted because of an invalid user input.
What can I do with it?
Your system headers contain non-standard syntax extensions that are not supported by Frama-C. This is normal, as the headers are often provided as part of a complete package with the compiler, so the headers and the compiler only need to work together, not to work with all the other programs that take C source code as input.
Generally speaking, you should always use the headers provided with Frama-C
instead of those from your system.
When using GCC or a compatible compiler such as Clang, this involves
passing the pre-processor the options -nostdinc and -I... where ...
stands for the place where Frama-C's headers were installed. This
location can be obtained from Frama-C with the option -print-share-path.
All in all, on a Unix system, it may look like:
frama-c -cpp-extra-args=-nostdinc -cpp-extra-args=-I`frama-c -print-share-path`/libc .....
Doing the same thing with Windows and MinGW follows the same idea but sometimes involves extra trouble due to the perpetual ambiguity between \ and / as directory separators.
Recently, Frank Dordowsky has been having trouble with using a very new GCC version to pre-process C files for Frama-C. That was only when using -pp-annot, but in any case, the solution was to switch to Clang as pre-processor.
My project is using both Qt (included Qwt) and Boost::signals. As known, their macros are incompatible with each other. I compiled my project with CONFIG += no_keywords and renamed all Qt macros with upper-case registry i.e. signals = Q_SIGNALS. There are no more errors in project, but now I have errors in Qwt includes like this
/usr/include/qwtplot3d/qwt3d_extglwidget.h:101:1: error: ‘signals’ does not name a type
/usr/include/qwtplot3d/qwt3d_extglwidget.h:116:8: error: expected ‘:’ before ‘slots’
/usr/include/qwtplot3d/qwt3d_extglwidget.h:116:8: error: ‘slots’ does not name a type
It seems that Qwt is still conflicting with Boost::signals. What can I do here?
Qwt is compatible with boost signals - you are talking about a lib called QwtPlot3D !
When you want to use boost signals with QwtPlot3D you have to patch its implementation replacing the signal/slot/emit macros like you did it with your code.
Here is the code:
#include <QtCore/QCoreApplication>
#include <QProcess>
#include <QProcessEnvironment>
int main(int argc, char *argv[])
{
QProcessEnvironment env;
// Environment variables required by CGI apps
env.insert("QUERY_STRING", url.encodedQuery());
env.insert("REQUEST_URI", url.toString());
env.insert("REQUEST_METHOD", "GET");
env.insert("REMOTE_ADDR", pSocket->peerAddress().toString());
//==========
QProcess process;
process.setProcessEnvironment(env);
process.start("php-cgi",QProcess::ReadWrite);
process.write("<?php print_r($_GET); ?>");
process.closeWriteChannel();
process.waitForFinished();
qDebug(process.readAll().data());
return 0;
}
Qt Creator reports more than 14000 errors. Here is a small sample of them:
In file included from ../QProcess/main.cpp:2:
../QProcess/QProcess:1: error: stray ‘\177’ in program
../QProcess/QProcess:1: error: stray ‘\2’ in program
../QProcess/QProcess:1: error: stray ‘\1’ in program
../QProcess/QProcess:1: error: stray ‘\1’ in program
In file included from ../QProcess/main.cpp:2:
../QProcess/QProcess:1:8: warning: null character(s) ignored
../QProcess/QProcess:1: error: stray ‘\2’ in program
Here is a simple example instance of this error. The contents of a file called new.cpp:
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Brand new." << std::endl;
return 0;
}
Now compile it:
ppu32-g++ new.cpp -o new
No problem. Let's compile it again:
ppu32-g++ new.cpp -o new
OMG! Screen after screen of errors! Most of these errors look like this:
./new:1: error: stray '\177' in program
The problem is that the compiler is trying to use the new file in the current directory, as the C++ standard library <new>; used by <iostream>. In fact any file in the current directory, named after a C++ standard library header, which is used in the code being compiled, will likely cause an error. That our problem file is an executable obfuscates the error messages.
It doesn't occur on all the gcc machines I've tried. ppu32-g++ 4.1.1 on PS3 Cell Fedora Linux certainly chokes.
If that problem arises not on every host then probably difference in the compiler. Difference is likely in the header files directory scan order.
Such error should not arise if standard headers directory scanned before others.
As a workaround its enough to remove project target file manually befor building target. But this is not a programmers way (which are very lazy creatures).
Programmers way - is to learn QMake to delete target file just before project sources compilations (but under this way link phase will be done permanently). For me (QMake 2.01a under Linux) this is achived by addition of following lines into project file:
deltarget.commands = $$QMAKE_DEL_FILE $$TARGET
QMAKE_EXTRA_TARGETS += deltarget
PRE_TARGETDEPS += deltarget
This declares target deltarget which becomes built before current project.
This sample uses undeclared in QMake's manual variable QMAKE_DEL_FILE which used to remove files (its content of course platfrom-dependent).