Building an R package in Windows - r

I am trying to build an R package in Windows using Rtools v3.4 (latest)
I have developed a package with Rcpp and I have built it in an Ubuntu system successfully, but when I try to build it in my Windows 10 machine with the command
R CMD INSTALL --build --compile-both mypackage
I got the following error:
file1.hpp:25:18: required from here
C:/Rtools/mingw_32/i686-w64-mingw32/include/c++/ext/new_allocator.h:110:30: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
{ ::operator delete(__p); }
My Makefile.win file has this lines:
PKG_CPPFLAGS=-I./dep1/src -I./dep2/cudd -I./dep2/mtr -I./dep2/cplusplus -I./dep2/dddmp -I./dep2/util -I./dep2
CXX_STD=CXX11
PKG_LIBS=-llib1 -lm -fPIC -L./include/windows -llib2
What could be the reasson of that error?
Edit after #DirkEddelbuettel comment:
If add the -fpermissive flag I solve that issue, but a new error appears
R CMD INSTALL --build --compile-both -fpermissive mypackage
file1.hpp:95:71: required from here
C:/Rtools/mingw_32/i686-w64-mingw32/include/c++/bits/stl_construct.h:75:7: error: invalid static_cast from type 'const std::basic_string<char>*' to type 'void*'
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
The conflicting class has the following structure:
#ifndef __myKconf__configInfo__
#define __myKconf__configInfo__
#include <iostream>
#include <map>
#include <vector>
class myClass : public parentClass {
public :
myClass() {
...
}
//some public methods
void addToMenu(const std::string& s) {
contents.push_back(s);
}
private:
std::vector<const std::string> contents;
//more private elements
};
#endif

Very difficult to add to a constant string...
private:
std::vector<const std::string> contents;
//more private elements
Make it:
private:
std::vector<std::string> contents;
And you should be golden

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.

user-defined literals and whitespace and c++11 issues

I'm compiling very simple code and as output I receive error:
`../untitled6/main.cpp:17:1: error: unable to find string literal operator 'operator"" __FILE__'
connect(&d_t, SIGNAL(timeout()), this, SLOT(doPlay()));`
The code is following:
#include <QObject>
#include <QTimer>
class Test : public QObject
{
Q_OBJECT
public:
explicit Test(QObject *parent = 0) : QObject(parent) {}
void Play()
{
connect(&d_t, SIGNAL(timeout()), this, SLOT(doPlay()));
}
public slots:
void doPlay() {}
private:
QTimer d_t;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Test test;
test.Play();
return a.exec();
}
It is happened only if I include c++11 support in my project. Without this support the compilation is Okey. I have read about user-defined literals and whitespace for gcc ver. 4.7 when c++11 support is included. But my code doesn't include any FILE code.... I found that problem is related to SIGNAL and SLOT constructions. But I have no idea what is wrong here...
P.S. For compilation I use sh4-linux-g++ (GCC) 4.8.
I have found that this issue don't observed for release build configuration. It seems it is issue for debug build configuration...
This has been fixed in Qt 4.8.1:
https://bugreports.qt.io/browse/QTBUG-22847
You should upgrade.

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)

Linker error: Qt and libusb-win32

I try to develop a Qt GUI application which will communicate with a board using USB. The library I use is libusb-win32 v1.2.5.0.
When I compile the application, the following errors occur:
./debug/thread_usb_comm.o: In function `ZN15thread_usb_comm15find_usb_deviceEtt':
thread_usb_comm.cpp:15: undefined reference to 'usb_find_busses'
thread_usb_comm.cpp:16: undefined reference to 'usb_find_devices'
thread_usb_comm.cpp:18: undefined reference to 'usb_get_busses'
thread_usb_comm.cpp:26: undefined reference to 'usb_open'
collect2: ld returned 1 exit status
mingw32-make[1]: [debug/CALSYS11_calib_app.exe] Error 1
mingw32-make: [debug] Error 2
The application code is:
(header file)
#ifndef THREAD_USB_COMM_H
#define THREAD_USB_COMM_H
#include <QThread>
#include <QtDebug>
#include "CALSYS11.h"
#include <lusb0_usb.h>
class thread_usb_comm : public QThread
{
Q_OBJECT
public:
thread_usb_comm();
private:
bool device_connected;
usb_dev_handle *p_usb_device;
bool find_usb_device(
unsigned short vendor_id,
unsigned short product_id
);
};
#endif // THREAD_USB_COMM_H
(source file)
#include "thread_usb_comm.h"
thread_usb_comm::thread_usb_comm()
{
device_connected = false;
}
bool thread_usb_comm::find_usb_device(
unsigned short vendor_id,
unsigned short product_id
)
{
struct usb_bus *bus;
struct usb_device *dev;
usb_find_busses();
usb_find_devices();
for (bus = usb_get_busses(); bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
if ((dev->descriptor.idVendor == vendor_id) &&
(dev->descriptor.idProduct == product_id))
{
qDebug ("Device found");
p_usb_device = usb_open(dev);
if (0 == p_usb_device)
{
qCritical ("Could not open USB device");
return false;
}
device_connected = true;
return true;
}
}
}
qDebug ("Cannot find specified device");
return false;
}
I added the link to the libusb library in the .pro file:
LIBS += -L\path\to\libusb-win32\lib\gcc -lusb
I develop on Windows 7.
Thank you,
Johann
Try to build release instead of debug or the static library is incompatible with compiler version (I faced same issue when I tried to build old static library with MinGW 4.4)

error: ‘QtMobility’ is not a namespace-name

I am trying to compile: http://wiki.forum.nokia.com/index.php/Fetching_a_map_tile_in_Qt_using_Google_Maps
I am using Qt-Mobility 1.2 with Qt 4.7 on OpenSuse 11.2
The errors I am receiving are:
MainWindow.h:7: error: ‘QtMobility’ is not a namespace-name
MainWindow.h:7: error: expected namespace-name before ‘;’ token
MainWindow.h:10: error: expected class-name before ‘{’ token
In file included from /opt/qtsdk-2010.05/qt/include/QtCore/qcoreapplication.h:47,
from /opt/qtsdk-2010.05/qt/include/QtGui/qapplication.h:45,
from /opt/qtsdk-2010.05/qt/include/QtGui/QApplication:1,
from main.cpp:2:
/opt/qtsdk-2010.05/qt/include/QtCore/qeventloop.h:51: error: expected initializer before ‘QtCoreModule’
make: *** [main.o] Error 1
My .pro file contains:
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
HEADERS += MainWindow.h
SOURCES += main.cpp MainWindow.cpp
QT += network
CONFIG += mobility
MOBILITY = location
The error is reported in the header file, which I have shown as follows:
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QPaintEvent>
#include <QPixmap>
using namespace QtMobility;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow ();
void paintEvent(QPaintEvent* paintEvent);
public slots:
void handleNetworkData(QNetworkReply* reply);
private:
void fetchMap(const QSize& size, qreal latitude, qreal longitude);
private:
QNetworkAccessManager networkAccessManager;
QPixmap mapPixmap;
}
Please guide.
You'll need to include at least one QtMobility header to be able to use that namespace.
Also that using namespace declaration is not the recommended way anymore. Use:
QTM_USE_NAMESPACE
instead (see QtMobility QuickStart).

Resources