problems with gcc-versions when compiling c++ code.
-
I am not sure if this is a cuda issue or a qmake/qtcreator config issue but here is the output.
12:06:16: Running steps for project SuperRes... 12:06:16: Configuration unchanged, skipping qmake step. 12:06:16: Starting: "/usr/bin/make" Makefile:3001: warning: overriding recipe for target 'moc_mainviewer.cpp' Makefile:2501: warning: ignoring old recipe for target 'moc_mainviewer.cpp' Makefile:3221: warning: overriding recipe for target 'moc_mainwindow.cpp' Makefile:2390: warning: ignoring old recipe for target 'moc_mainwindow.cpp' Makefile:3679: warning: overriding recipe for target 'ui_mainwindow.h' Makefile:3675: warning: ignoring old recipe for target 'ui_mainwindow.h' Makefile:4638: warning: overriding recipe for target '../SuperRes/Obj/main.o' Makefile:3867: warning: ignoring old recipe for target '../SuperRes/Obj/main.o' Makefile:5295: warning: overriding recipe for target '../SuperRes/Obj/mainwindow.o' Makefile:3994: warning: ignoring old recipe for target '../SuperRes/Obj/mainwindow.o' /usr/local/cuda-9.1//bin/nvcc -m64 -O3 -c --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -I/usr/local/cuda-9.1/include/ -I/usr/local/cuda-9.1/include/ -L/usr/local/cuda-9.1/lib64/ -lcuda -lcudart -L/usr/local/cuda-9.1/lib64/ -lcudart -lcuda ../SuperRes/Filter.cu -o ../SuperRes/Obj/Filter_cuda.o 2>&1 | sed -r "s/\(([0-9]+)\)/:\1/g" 1>&2 In file included from /usr/local/cuda-9.1/include/host_config.h:50:0, from /usr/local/cuda-9.1/include/cuda_runtime.h:78, from <command-line>:0: /usr/local/cuda-9.1/include/crt/host_config.h:121:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported! #error -- unsupported GNU version! gcc versions later than 6 are not supported! ^~~~~ /usr/local/cuda-9.1//bin/nvcc -m64 -O3 -c --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -I/usr/local/cuda-9.1/include/ -I/usr/local/cuda-9.1/include/ -L/usr/local/cuda-9.1/lib64/ -lcuda -lcudart -L/usr/local/cuda-9.1/lib64/ -lcudart -lcuda ../SuperRes/SuperResolutionKernel.cu -o ../SuperRes/Obj/SuperResolutionKernel_cuda.o 2>&1 | sed -r "s/\(([0-9]+)\)/:\1/g" 1>&2 In file included from /usr/local/cuda-9.1/include/host_config.h:50:0, from /usr/local/cuda-9.1/include/cuda_runtime.h:78, from <command-line>:0: /usr/local/cuda-9.1/include/crt/host_config.h:121:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported! #error -- unsupported GNU version! gcc versions later than 6 are not supported! ^~~~~ /usr/local/cuda-9.1//bin/nvcc -D_DEBUG --use_fast_math -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -I/usr/local/cuda-9.1/include/ -I/usr/local/cuda-9.1/include/ --machine 64 -c -o Filter_cuda.o ../SuperRes/Filter.cu In file included from /usr/local/cuda-9.1/include/host_config.h:50:0, from /usr/local/cuda-9.1/include/cuda_runtime.h:78, from <command-line>:0: /usr/local/cuda-9.1/include/crt/host_config.h:121:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported! #error -- unsupported GNU version! gcc versions later than 6 are not supported! ^~~~~ Makefile:2212: recipe for target 'Filter_cuda.o' failed make: *** [Filter_cuda.o] Error 1 12:06:17: The process "/usr/bin/make" exited with code 2. Error while building/deploying project SuperRes (kit: Desktop Qt 5.11.0 GCC 64bit) When executing step "Make" 12:06:17: Elapsed time: 00:00.
I have tried the following:
-
changing the compiler in Tools>Options>Kits as in this screenshot.
- I do get a warning saying
:-1: warning: "/usr/bin/gcc-6" is used by qmake, but "/usr/bin/x86_64-linux-gnu-gcc-5" is configured in the kit. Please update your kit or choose a mkspec for qmake that matches your target environment better.
and likewise for G++ however as you can see it's just a different path. I actually went into the Qt mkspec files and changed it to gcc-5. I will go into detail about that next.
-
Changing the options in the Qt mkspec files.
- I went into the "linux-g++-64" and "linux-g++" mkspec folders (liux-g++ is the one it said it uses by default but I manually set the kit to use linux-g++-64) and followed the included files and changed all the options to gcc-5 and g++-5 respectively. You can see that it worked in the warning above.
-
Changing options in my Project.pro file
- I changed SuperRes.pro and here is the current contents.
#------------------------------------------------- # # Project created by QtCreator 2018-06-01T16:27:25 # #------------------------------------------------- QT += core \ network \ gui \ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = SuperRes TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ mainwindow.cpp \ FileThread.cpp \ ImageFloatViewer.cpp \ ImageIntViewer.cpp \ ImgRead.cpp \ main.cpp \ MainViewer.cpp \ mainwindow.cpp \ StatusViewer.cpp \ Stopwatch.cpp \ SuperResolution.cpp \ SuperResolutionThread.cpp \ SuperResolutionViewer.cpp \ UDPRead.cpp HEADERS += \ mainwindow.h \ mainviewer.h \ statusdata.h \ cudaError.h \ cudaMath.h \ FileThread.h \ Filter.h \ ImageFloatViewer.h \ ImageHeader.h \ ImageIntViewer.h \ ImgRead.h \ mainviewer.h \ MainViewer.h \ mainwindow.h \ statusdata.h \ StatusData.h \ StatusViewer.h \ Stopwatch.h \ SuperResolution.h \ SuperResolutionKernel.h \ SuperResolutionThread.h \ SuperResolutionViewer.h \ UDPRead.h \ FORMS += \ mainwindow.ui \ mainwindow.ui DISTFILES += \ SuperResViewer.suo \ SuperRes.pro.user \ SuperRes.pro.autosave \ SuperResViewer.sln \ SuperResViewer.vcxproj \ SuperResViewer.vcxproj.filters \ SuperResViewer.vcxproj.user \ Filter.cu \ SuperResolutionKernel.cu \ Filter.cu \ .cu SUBDIRS += \ SuperRes.pro INCLUDEPATH += /usr/local/cuda-9.1/include/ LIBS += -L"/usr/local/cuda-9.1/lib64/" -lcuda -lcudart #CONFIG += console #CONFIG -= app_bundle SYSTEM_TYPE = 64 DESTDIR = $$system(pwd) CUDA_OBJECTS_DIR = ./ OBJECTS_DIR = $$DESTDIR/Obj QMAKE_CXXFLAGS_RELEASE =-O3 -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 CUDA_SOURCES += Filter.cu \ SuperResolutionKernel.cu # Path to cuda toolkit install CUDA_DIR = /usr/local/cuda-9.1/ # Path to header and libs files INCLUDEPATH += /usr/local/cuda-9.1/include/ QMAKE_LIBDIR += /usr/local/cuda-9.1/lib64/ # Note I'm using a 64 bits Operating system # libs used in your code LIBS += -L"/usr/local/cuda-9.1/lib64/" -lcudart -lcuda # GPU architecture #CUDA_ARCH = sm_21 # Yeah! I've a new device. Adjust with your compute capability # Here are some NVCC flags I've always used by default. NVCC_OPTIONS = --use_fast_math -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 # Prepare the extra compiler configuration (taken from the nvidia forum - i'm not an expert in this part) CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ') #-arch=$$CUDA_ARCH cuda.commands = $$CUDA_DIR/bin/nvcc -m64 -O3 -c $$NVCCFLAGS -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 \ $$CUDA_INC $$LIBS ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} \ 2>&1 | sed -r \"s/\\(([0-9]+)\\)/:\\1/g\" 1>&2 # nvcc error printout format ever so slightly different from gcc # http://forums.nvidia.com/index.php?showtopic=171651 cuda.dependency_type = TYPE_C # there was a typo here. Thanks workmate! cuda.depend_command = $$CUDA_DIR/bin/nvcc -O3 -M $$CUDA_INC $$NVCCFLAGS -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 ${QMAKE_FILE_NAME} cuda.input = CUDA_SOURCES cuda.output = ${OBJECTS_DIR}${QMAKE_FILE_BASE}_cuda.o # Tell Qt that we want add more stuff to the Makefile QMAKE_EXTRA_COMPILERS += cuda # SPECIFY THE R PATH FOR NVCC (this caused me a lot of trouble before) QMAKE_LFLAGS += -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -Wl,-rpath,/usr/local/cuda-9.1/lib64/ # <-- added this NVCCFLAGS = -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -Xlinker -rpath,/usr/local/cuda-9.1/lib64/ # <-- and this #-arch=$$CUDA_ARCH CONFIG(debug, debug|release) { # Debug mode cuda_d.input = CUDA_SOURCES cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o cuda_d.commands = $$CUDA_DIR/bin/nvcc -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$NVCC_LIBS --machine $$SYSTEM_TYPE -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} cuda_d.dependency_type = TYPE_C QMAKE_EXTRA_COMPILERS += cuda_d } else { # Release mode cuda.input = CUDA_SOURCES cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o cuda.commands = $$CUDA_DIR/bin/nvcc $$NVCC_OPTIONS $$CUDA_INC $$NVCC_LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} cuda.dependency_type = TYPE_C QMAKE_EXTRA_COMPILERS += cuda }
I added
-DCMAKE_CXX_COMPILER=/usr/bin/g++-5
and-DCMAKE_CXX_COMPILER=/usr/bin/gcc-5
wherever I could be it the NVCC flags or qmake options. I just put it wherever I could and it hasn't raised any extra warnings or errors so I can't imagine it's doing any harm but it's definitely not fixing the errors.NOTE:
I was trying this with GCC/G++ 6 when I had 7 enabled first then I tried gcc/g++ 5 because I thought maybe it meant anything above 6.0 so 6.4.0 would also be bad. Again i do not know exactly what the cause of this is. I know it's coming from cuda not being compatible with GCC but I don't know if qt-creator might be what is setting the GCC version here. Thanks for your time.
NOTE2:
I wasn't sure what part of the forum to post this in. I thought General and Desktop might be appropriate.
-
-
Hi and welcome to devnet,
What Linux distribution are you running ?
-
Ok I just wasn't google searching the right phrases. This, at least, seems to fix the issue. Once I have successfully compiled the program I will delete this post or mark as a duplicate respecitvely.
https://stackoverflow.com/questions/14787148/cuda-and-gcc-compatibility-issue?rq=1
-
No reason to delete this post.
That will make the solution even more visible :)