Qt creator and cross compile for nvidia jetson nano
-
Hi,
I try to setup Qt creator for cross compile to nvidia jetson nano.
So I download gcc toolchain from nvidia which contains aarch64-unknown-linux-gnu-g++.Then I build and install qt from source with this parametrs:
../configure -xplatform linux-aarch64-gnu-g++ -device-option CROSS_COMPILE=/opt/nvidia/toolchain_28.3.2/bin/aarch64-unknown-linux-gnu- -sysroot /opt/nvidia/toolchain_28.3.2/aarch64-unknown-linux-gnu/sysroot -nomake examples -nomake tests -prefix /usr/local/qt5 -extprefix /opt/nvidia/toolchain_28.3.2/aarch64-unknown-linux-gnu/sysroot/usr/local/qt5 -hostprefix /opt/nvidia/toolchain_28.3.2/qt5-host -opengl es2
Next I rsync my /usr/include and /usr/lib from jetson nano to /opt/nvidia/toolchain_28.3.2/aarch64-unknown-linux-gnu/sysroot/usr
In Qt creator I create kit where set qt path to:
/opt/nvidia/toolchain_28.3.2/qt5-host/bin/qmake
Sysroot path to:
/opt/nvidia/toolchain_28.3.2/aarch64-unknown-linux-gnu/sysroot
and set C and C++ compiler to:
/opt/nvidia/toolchain_28.3.2/bin/aarch64-unknown-linux-gnu-g++ /opt/nvidia/toolchain_28.3.2/bin/aarch64-unknown-linux-gnu-gcc
I the system I have also Instaled aarch64-linux-gnu-gcc and aarch64-linux-gnu-g++ which cames with nvidia SDK.
And now my problem. When I try to compile the basic qt helloWorld with the kit then I seeaarch64-linux-gnu-g++ -c -pipe --sysroot=/opt/nvidia/toolchain_28.3.2/aarch64-unknown-linux-gnu/sysroot -std=c++11 -g -std=gnu++11 -Wall -W -fPIC -DQT_QML_DEBUG -I../untitled -I. -I/opt/nvidia/toolchain_28.3.2/qt5-host/mkspecs/linux-aarch64-gnu-g++ -o main.o ../untitled/main.cpp aarch64-linux-gnu-g++ --sysroot=/opt/nvidia/toolchain_28.3.2/aarch64-unknown-linux-gnu/sysroot -o unitled main.o 13:55:12: The process "/usr/bin/make" exited normally. 13:55:12: Elapsed time: 00:00.
Problem is that is used aarch64-linux-gnu-g++ instead of aarch64-unknown-linux-gnu-g++ and are not used libs and header files from sysroot but from /usr/aarch64-linux-gnu path. Plus in qt creator I see the red underline:
iostream file not found
even the compile works fine. See in the screen shot (https://ibb.co/McLXXdx).
When I run qmake I see this?
14:19:16: Starting: "/opt/nvidia/toolchain_28.3.2/qt5-host/bin/qmake" /home/pac_jakub/untitled/untitled.pro -spec linux-aarch64-gnu-g++ CONFIG+=debug CONFIG+=qml_debug 14:19:16: The process "/opt/nvidia/toolchain_28.3.2/qt5-host/bin/qmake" exited normally.
If I configure kit to aarch64-linux-gnu-g++ everything works fine, red underline disappears but also are not used libs from sysroot.
My question is how to configure cross compile to use libs and header files from sysroot with indexer working fine. I don't really care if I use aarch64-linux-gnu-g++ or aarch64-unknown-linux-gnu-g++ beacause they are both recommended by nvidia.
Is something wrong with configuration of crooscompile qt? Or I need setup some enviroment ? Or somethink else?Thank you for your help
-
Finally i found a solution
Instal cuda toolkit, in project kit set compiler path to :
/usr/bin/aarch64-linux-gnu-g++
set the sysroot path and in .pro file add this code :
CUDA_DIR = /usr/local/cuda-10.0 CUDA_SOURCES += cuda_function.cu CUDA_ARCH = sm_53 NVCC_OPTIONS = --use_fast_math HOST_COMPILER=$$QMAKE_CXX LIB_PATH=x86_64-linux equals(HOST_COMPILER, "aarch64-linux-gnu-g++") { LIB_PATH=aarch64-linux } INCLUDEPATH += $$[QT_SYSROOT]/$$CUDA_DIR/targets/$$LIB_PATH/include INCLUDEPATH += $$[QT_SYSROOT]/usr/local/cuda/samples/common/inc QMAKE_LIBDIR += $$[QT_SYSROOT]/$$CUDA_DIR/targets/$$LIB_PATH/lib LIBS += -L $$[QT_SYSROOT]/$$CUDA_DIR/targets/$$LIB_PATH/lib -lcudart -lcuda -lcublas CONFIG(debug, debug|release) { #debug cuda_d.commands = $$CUDA_DIR/bin/nvcc -ccbin $$HOST_COMPILER -D_DEBUG $$NVCC_OPTIONS -m64 -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} cuda_d.dependency_type = TYPE_C cuda_d.input = CUDA_SOURCES cuda_d.output = cuda/${QMAKE_FILE_BASE}.o QMAKE_EXTRA_COMPILERS += cuda_d } else { #release cuda.commands = $$CUDA_DIR/bin/nvcc -ccbin $$HOST_COMPILER $$NVCC_OPTIONS -m64 -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} cuda.dependency_type = TYPE_C cuda.input = CUDA_SOURCES cuda.output = cuda/${QMAKE_FILE_BASE}.o QMAKE_EXTRA_COMPILERS += cuda }
And everything works fine
-
Do you have the link for download the toolchain from nvidia? I'm trying to build a simple "Hello World" project, but i can't do this. Could you help me?