3

I'm running on a Ubuntu 16.04 where I installed gcc4.9 and NVIDA drivers from official repositories, configured alternatives for gcc, and installed the CUDA toolkit 7.5.18.

When I try to compile a CUDA code, I get a lot of messages like this

/usr/lib/gcc/x86_64-linux-gnu/5/include/avx2intrin.h(247): error: ...

How can I force the system to use gcc-4.9 headers and not gcc-5?

I use cmake and make to compile the source code.

Thank you

  • why you dont want to use gcc-5 for CUDA? the gcc version to use nvcc doesnt matter – pradyot Jun 16 '16 at 6:58
1

You'll want to add a -Idir flag to your CXX flags in the make file and likely the cmake file. The dir would be the path to the headers you do want to use. If just including the proper directories doesn't work then it would be best to also disable the default include paths with --nostdinc but this shouldn't be needed since it searches the include directories first. To add these flags to the cmake files you have to specify something along the lines of

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -L/usr/local/lib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")

from an answer about setting the cmake flags. (The -L flag is to specify libraries that are only searched for in the "" style includes and not the <> style)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.