Build issue in Qt - qt

I am new in Qt. I am trying to build my project in Qt 5.5.1 but getting the following error. What could be reason for this?
Error Snapshot:
---------------------------------------
18:56:20: Starting: "C:\Qt\Qt5.5.1\Tools\mingw492_32\bin\mingw32-make.exe"
C:/Qt/Qt5.5.1/Tools/mingw492_32/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/Perforce_Client/project/src'
g++ -c -pipe -fno-keep-inline-dllexport -Wp,-isystem,D:/Perforce_Client/target/win32/usr/include -fno-strict-aliasing -Werror -O2 -std=c++0x -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I..\..\target\win32\usr\include -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtQuick -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtGui -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtANGLE -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtQml -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtNetwork -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtConcurrent -IC:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtCore -Iobj -IC:\Qt\Qt5.5.1\5.5\mingw492_32\mkspecs\win32-g++ -o obj\myGen3.o main\myGen3.cc
In file included from C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobject.h:40:0,
from C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qiodevice.h:39,
from C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qfiledevice.h:37,
from C:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtCore/qfile.h:37,
from C:\Qt\Qt5.5.1\5.5\mingw492_32\include\QtCore/QFile:1,
from main\myGen3.cc:6:
C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobjectdefs.h:164:65: error: variable or field 'qt_static_metacall' declared void
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
^
C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobjectdefs.h:164:65: error: 'QObject' was not declared in this scope
C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobjectdefs.h:164:74: error: expected primary-expression before ',' token
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
^
C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobjectdefs.h:164:76: error: incomplete type 'QMetaObject' used in nested name specifier
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
^
C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobjectdefs.h:164:95: error: expected primary-expression before 'int'
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
^
C:\Qt\Qt5.5.1\5.5\mingw492_32\include/QtCore/qobjectdefs.h:164:100: error: expected primary-expression before 'void'
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
---------------------------------------
I am using Qt Creator 3.5.1 (enterprise) based on Qt 5.5.1 (MSVC 2013, 32 bit).
Build&Run -> Kits configuration is: Desktop QT5.5.1 MinGW 32 bit

Related

Does clang support CUDA __global__ function recursion?

nvcc has supported recursive __global__ functions. What about clang? I failed to compile the following code (using clang++ -o helloWorld helloWorld.cu --cuda-gpu-arch=sm_75 -ldl -lrt -lcudart_static -pthread -L/usr/local/cuda/lib64 -std=c++14):
#include <stdio.h>
__global__ void cuda_hello(int i){
printf("Hello World from GPU!\n");
if (i < 3) {
cuda_hello<<<1,1>>>(i+1);
}
}
int main() {
cuda_hello<<<1,1>>>(0);
return 0;
}
. The error I got is
helloWorld.cu:6:3: error: reference to __global__ function 'cuda_hello' in __global__ function
cuda_hello<<<1,1>>>(i+1);
^
helloWorld.cu:3:17: note: 'cuda_hello' declared here
__global__ void cuda_hello(int i){
Anyone knows if/how clang supports such recursion?
At the time of writing (July 2020), it would appear that while separate compilation support has been added to clang, dynamic parallelism ("nested kernels") is still not supported.

Using QtWebEngine with X forwarding

I just can't get webengine working. This is my source code:
#include <QtWidgets/QApplication>
#include <QtWebEngineWidgets/QWebEngineView>
int main(int argc, char ** argv) {
QApplication app(argc, argv);
QWebEngineView view;
view.setUrl(QUrl(QStringLiteral("http://www.qt.io")));
view.resize(1024, 750);
view.show();
return app.exec();
}
And this happens when I try to run it:
$ g++ test.cpp -I/usr/include/qt -fPIC -lQt5Core -lQt5Gui -lQt5Widgets -lQt5WebEngine -lQt5WebEngineWidgets && ./a.out
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Unrecognized OpenGL version
Unrecognized OpenGL version
No windows is shown and it just hangs there until I kill it with ^C. How can I get it to work?

move semantics for different qt versions

Am beginner in move semantics and I'm confused by compilation result. When I use qt 5.5.1 all are okey, but when I use qt 4.8.7 I have build errors. I'm trying to build the following code:
struct TResource
{
int _resource_id = 18;
};
typedef std::vector<std::unique_ptr<TResource>> TResources;
struct TChannel
{
QString _title;
TResources _ress;
};
typedef std::vector<TChannel> TChanneles;
int main(int , char **)
{
TChannel channel;
TChanneles chnls;
//Creating some channel resorces and place it to the vector
// .......
chnls.push_back(std::move(channel));
return 0;
}
The error messages are following:
g++ -c -m64 -pipe -std=c++0x -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -o main.o main.cpp
In file included from /usr/include/c++/5/bits/stl_tempbuf.h:60:0,
from /usr/include/c++/5/bits/stl_algo.h:62,
from /usr/include/c++/5/algorithm:62,
from /usr/include/qt4/QtCore/qglobal.h:68,
from /usr/include/qt4/QtCore/qnamespace.h:45,
from /usr/include/qt4/QtCore/qobjectdefs.h:45,
from /usr/include/qt4/QtCore/qobject.h:47,
from /usr/include/qt4/QtCore/qcoreapplication.h:45,
from /usr/include/qt4/QtCore/QCoreApplication:1,
from main.cpp:1:
/usr/include/c++/5/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::unique_ptr<TResource>; _Args = {const std::unique_ptr<TResource, std::default_delete<TResource> >&}]’:
/usr/include/c++/5/bits/stl_uninitialized.h:75:18: required from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<TResource>*, std::vector<std::unique_ptr<TResource> > >; _ForwardIterator = std::unique_ptr<TResource>*; bool _TrivialValueTypes = false]’
/usr/include/c++/5/bits/stl_uninitialized.h:126:15: required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<TResource>*, std::vector<std::unique_ptr<TResource> > >; _ForwardIterator = std::unique_ptr<TResource>*]’
/usr/include/c++/5/bits/stl_uninitialized.h:281:37: required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<TResource>*, std::vector<std::unique_ptr<TResource> > >; _ForwardIterator = std::unique_ptr<TResource>*; _Tp = std::unique_ptr<TResource>]’
/usr/include/c++/5/bits/stl_vector.h:322:31: required from ‘std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<TResource>; _Alloc = std::allocator<std::unique_ptr<TResource> >]’
main.cpp:11:8: required from ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = TChannel; _Args = {TChannel&}]’
/usr/include/c++/5/bits/stl_uninitialized.h:75:18: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/c++/5/bits/stl_uninitialized.h:281:37: required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = TChannel*; _ForwardIterator = TChannel*; _Tp = TChannel]’
/usr/include/c++/5/bits/stl_uninitialized.h:303:2: required from ‘_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = TChannel*; _ForwardIterator = TChannel*; _Allocator = std::allocator<TChannel>]’
/usr/include/c++/5/bits/vector.tcc:422:8: required from ‘void std::vector<_Tp, _Alloc>::_M_emplace_back_aux(_Args&& ...) [with _Args = {TChannel}; _Tp = TChannel; _Alloc = std::allocator<TChannel>]’
/usr/include/c++/5/bits/vector.tcc:101:23: required from ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {TChannel}; _Tp = TChannel; _Alloc = std::allocator<TChannel>]’
/usr/include/c++/5/bits/stl_vector.h:932:21: required from ‘void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = TChannel; _Alloc = std::allocator<TChannel>; std::vector<_Tp, _Alloc>::value_type = TChannel]’
main.cpp:26:39: required from here
/usr/include/c++/5/bits/stl_construct.h:75:7: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = TResource; _Dp = std::default_delete<TResource>]’
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
^
In file included from /usr/include/c++/5/memory:81:0,
from main.cpp:2:
/usr/include/c++/5/bits/unique_ptr.h:356:7: note: declared here
unique_ptr(const unique_ptr&) = delete;
^
Makefile:203: recipe for target 'main.o' failed
make: *** [main.o] Error 1
It seems that something not supported in qt 4.8.7 and I should take this into account and change my code. But I don't know what change.
Thank you in advance.
I have fixed my issue.
A have added move constructor TChannel struct:
TChannel(TChannel&& that)
{
_title = std::move(that._title);
}
It helped because move constructor was introduced in Qt 5.2.

Rcpp compile error: cannot convert List to SEXP

If I adapt some working Rcpp code to put it into a class, it stops working.
Here is the working, non-class-based code:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
List test1_() {
Rcpp::NumericVector x = Rcpp::NumericVector::create(1.0);
return Rcpp::List::create(Rcpp::Named("x") = x);
}
But when I separate it into .cpp ...
// testlist.cpp
#include <Rcpp.h>
#include "testlist.h"
using namespace Rcpp;
// [[Rcpp::export]]
SEXP test2_() {
testlist a_testlist;
return a_testlist.test;
}
... and .h ...
// testlist.h
#ifndef TESTLIST_
#define TESTLIST_
#include <Rcpp.h>
class testlist {
public:
testlist() {}
Rcpp::List test() {
Rcpp::NumericVector x = Rcpp::NumericVector::create(1.0);
return Rcpp::List::create(Rcpp::Named("x") = x);
}
};
#endif
... then I get the following compilation error.
g++ -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -I"/home/nacnudus/R/x86_64-pc-linux-gnu-library/3.3/Rcpp/include" -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -I"/home/nacnudus/R/x86_64-pc-linux-gnu-library/3.3/Rcpp/include" -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -c testlist.cpp -o testlist.o
testlist.cpp: In function ‘Rcpp::List test2_()’:
testlist.cpp:8:21: error: cannot convert ‘testlist::test’ from type ‘Rcpp::List (testlist::)() {aka Rcpp::Vector<19> (testlist::)()}’ to type ‘Rcpp::List {aka Rcpp::Vector<19>}’
return a_testlist.test;
^~~~
make: *** [/usr/lib64/R/etc/Makeconf:141: testlist.o] Error 1
ERROR: compilation failed for package ‘testlist’
* removing ‘/tmp/RtmppNxPq5/devtools_install_f654fb60a32/testlist’
What am I doing wrong?
Simple typo:
return a_testlist.test;
Needs to be:
return a_testlist.test();
Though, you should consider reading the Rcpp-modules vignette to properly expose classes.

QT Mingw not able to compile template class

I am compiling a project using MSVC2010 compiler i am compiling it against following library (Qt\4.8.1\msvc2010) In that case compilation is successful with no error.
Now I am trying to compilng a QT app using minGW using following library (Qt\4.7.4\mingw).Then i am getting following error.
devicethreadobject.h include following file event.h.
Event.h file contains few template class.
Does MinGW have problem while working with template ?
Why compilation is successfull with MSVC compiler & fails with MINGW compiler ?
Event.h file :----
#ifndef EVENT_H
#define EVENT_H
#include <QtGui>
#include <QEvent>
//String event derived class
template <typename T> class StringEvent : public QEvent
{
QString m_str;
public:
explicit StringEvent(const QString val) : QEvent(staticType()), m_str(val)
{
}
void setvalue(QString val)
{
m_str = val;
}
QString value() const
{
return m_str;
}
static QEvent::Type staticType()
{
static int type = QEvent::registerEventType();
return static_cast<QEvent::Type>(type);
/*
static int type;
if(type == 0)
{
type = QEvent::registerEventType();
}
return static_cast<QEvent::Type>(type);*/
}
static bool is(const QEvent * ev)
{
return ev->type() == staticType();
}
};
class UpdateEvent : public StringEvent<UpdateEvent>
{
public:
explicit UpdateEvent(QString val): StringEvent(val)
{
//qDebug() << "hello";
}
};
class ClearEvent : public StringEvent<ClearEvent>
{
public:
explicit ClearEvent(QString val): StringEvent(val)
{
}
};
#endif // EVENT_H
Error :---
18:23:08: Running build steps for project CanSewLyzer_vs...
18:23:08: Starting: "c:\qtsdk\desktop\qt\4.7.4\mingw\bin\qmake.exe" D:\Stryker\Stryker\Qt\AutoS\CanSewLyzer_err_mingw\CanSewLyzer_vs\CanSewLyzer_vs.pro -r -spec win32-g++ "CONFIG+=release"
18:23:09: The process "c:\qtsdk\desktop\qt\4.7.4\mingw\bin\qmake.exe" exited normally.
18:23:09: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Release
mingw32-make.exe[1]: Entering directory `D:/Stryker/Stryker/Qt/AutoS/CanSewLyzer_err_mingw/CanSewLyzer_vs-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release'
c:/QtSDK/Desktop/Qt/4.7.4/mingw/bin/uic.exe ../CanSewLyzer_vs/mainwindow.ui -o ui_mainwindow.h
g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/include/QtCore' -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/include/QtGui' -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/include' -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/include/ActiveQt' -I'release' -I'.' -I'../CanSewLyzer_vs' -I'.' -I'c:/QtSDK/Desktop/Qt/4.7.4/mingw/mkspecs/win32-g++' -o release/main.o ../CanSewLyzer_vs/main.cpp
In file included from ../CanSewLyzer_vs/../../geny/common/mythread/devicethreadobject.h:8,
from ../CanSewLyzer_vs/mainwindow.h:9,
from ../CanSewLyzer_vs/main.cpp:2:
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h: In constructor 'UpdateEvent::UpdateEvent(QString)':
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:56: error: class 'UpdateEvent' does not have any field named 'StringEvent'
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:56: error: no matching function for call to 'StringEvent<UpdateEvent>::StringEvent()'
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:18: note: candidates are: StringEvent<T>::StringEvent(QString) [with T = UpdateEvent]
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:15: note: StringEvent<UpdateEvent>::StringEvent(const StringEvent<UpdateEvent>&)
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h: In constructor 'ClearEvent::ClearEvent(QString)':
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:68: error: class 'ClearEvent' does not have any field named 'StringEvent'
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:68: error: no matching function for call to 'StringEvent<ClearEvent>::StringEvent()'
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:18: note: candidates are: StringEvent<T>::StringEvent(QString) [with T = ClearEvent]
../CanSewLyzer_vs/../../geny/common/mythread/../event/event.h:15: note: StringEvent<ClearEvent>::StringEvent(const StringEvent<ClearEvent>&)
mingw32-make.exe[1]: Leaving directory `D:/Stryker/Stryker/Qt/AutoS/CanSewLyzer_err_mingw/CanSewLyzer_vs-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release'
mingw32-make.exe[1]: *** [release/main.o] Error 1
mingw32-make.exe: *** [release] Error 2
18:23:14: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project CanSewLyzer_vs (target: Desktop)
When executing build step 'Make'*
It's not MinGW/GCC having issues with templates, it's MSVC being permissive about the syntax.
Change
explicit UpdateEvent(QString val): StringEvent(val)
...
explicit ClearEvent(QString val): StringEvent(val)
With
explicit UpdateEvent(QString val): StringEvent<UpdateEvent>(val)
...
explicit ClearEvent(QString val): StringEvent<ClearEvent>(val)

Resources