Implement root library to CUDA

Hi, i wrote this very simple code in C++:

#include <iostream>
#include "/home/casa/root/include/TRandom.h"
#include "/home/casa/root/include/TRandom3.h"
using namespace std;

int main() {
        TRandom *casuale = new TRandom3();
        for(int i=0;i<100;i++){
                int a = casuale -> Integer(1000);
                cout << a << endl;
        return 0;

and compiling with:

g++ prova.C -o b.exe `~/root/bin/root-config --cflags --glibs`

And it works!
But now i want to implement the same code with cuda, so i type:

nvcc -o b.exe `root-config -std=c++11 -m64 -I/home/casa/root/include -L/home/casa/root/lib -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -lm -ldl -rdynamic`

I used this because inside of “–cflags --glibs” there is “-pthread” that CUDA don’t know, so i specified all components without -pthread.
But it gives to me this error:

Unknown argument "-std=c++11"!
Usage: root-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--auxcflags] [--ldflags] [--new] [--nonew] [--libs] [--glibs] [--evelibs] [--bindir] [--libdir] [--incdir] [--etcdir] [--srcdir] [--noauxcflags] [--noauxlibs] [--noldflags] [--has-<feature>] [--arch] [--platform] [--config] [--features] [--ncpu] [--git-revision] [--python-version] [--cc] [--cxx] [--f77] [--ld ] [--help]
In file included from /home/casa/root/include/Rtypes.h:23:0,
                 from /home/casa/root/include/TObject.h:17,
                 from /home/casa/root/include/TNamed.h:25,
                 from /home/casa/root/include/TRandom.h:25,
/home/casa/root/include/RtypesCore.h:23:10: fatal error: ROOT/RConfig.h: File o directory non esistente
 #include <ROOT/RConfig.h>
compilation terminated.

What i have to do?

Instead of

#include "/home/casa/root/include/TRandom.h"

use just

#include "TRandom.h"
`root-config -std=c++11 -m64 -I/home/casa/root/include -L/home/casa/root/lib -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -lm -ldl -rdynamic`

use either

`root-config --cflags --libs`

or it expansion (i.e.:

-std=c++11 -m64 -I/home/casa/root/include -L/home/casa/root/lib -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -lm -ldl -rdynamic

I’ve resolved! I reinstalled root with the option that all header must to be in /usr/include so i can use:

#include <TRandom3.h>

instead of:

#include "TRandom3.h"

This fixed my problem.
The command to install root in this way is, at the moment to do “cmake”:

cmake ../root -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_INSTALL_INCLUDEDIR=/usr/include -Dgnuinstall=ON -Dall=ON -Dsoversion=ON

and than:

make -j<N>

where is the number of cores of your pc, and than:

make install

So i compiled my CUDA code with:

nvcc -m64 -L/usr/local/lib/root -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -lm -ldl

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.