OpenCV installation problem : nppiGraphcutInitAlloc not declared


I’m trying to install OpenCV 3.1.0 on my TX1, with JetPack 2.3.1, following this guide:

However when I reach 95% I get a bunch of build errors like:

/home/ubuntu/Downloads/opencv/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
     typedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppState, Npp8u* pDeviceMem);

I have downloaded the OpenCV source code from and built it as described in the link above.

As far as I can work out this is due to OpenCV 3.1.0 being released before Cuda V8.0.33 but then it somehow seems to have been fixed, although I’m not sure how to apply this fix… (got this info from here:

Any ideas on how to fix this?

So I’ve done some more research, and it seems that opencv3.1.0 downloaded from the website is not compatible with Cuda 8, and that I need to download the latest version from github instead according to

With that said, I’m now stuck with a half-compiled/installed version of OpenCV, could I simply “make clean” or

sudo find / -name "*opencv*" -exec rm -i {} \;

Or is there something else to do? maybe try the sudo make uninstall to make the uninstall manifest and then try that?
I don’t have opencv4tegra installed so removing all the files related to opencv should be ok?

Do you have cuda-npp-8.0 installed ?
What is the output of :

sudo apt search npp |grep installed


If is it not installed, you may try to install with:

sudo apt-get install cuda-npp-dev-8-0

Not sure the dev package is required, but this may solve more issues.

This issue could be resolved by following instructions described on this web page (sorry it’s in Chinese).

More precisely, modify this file “opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp” by replacing

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)


#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)  || (CUDART_VERSION >= 8000)

Hi again,
yes it seems that jkjung13’s answer would work, however now I’m stuck with OpenGL support instead…

The output of

sudo apt search npp |grep installed


cuda-npp-8-0/unknown,now 8.0.34-1 arm64 [installed,automatic]
cuda-npp-dev-8-0/unknown,now 8.0.34-1 arm64 [installed,automatic]

However, I’ve tried to compile it and install it a couple of times now, and I can never seem to get it to work, my error on the compilation is :

[ 14%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/opengl.cpp.o
In file included from /home/ubuntu/Downloads/opencv/opencv-3.1.0/modules/core/src/opengl.cpp:48:0:
/usr/local/cuda-8.0/include/cuda_gl_interop.h:64:2: error: #error Please include the appropriate gl headers before including cuda_gl_interop.h
 #error Please include the appropriate gl headers before including cuda_gl_interop.h

So now i seem to have opengl problems…

My CMake command is:


I’ll try to work it out, but if you have any ideas I would be grateful!

I would suggest to look for any configuration error with cmake-gui.
You may look at : if you don’t have it yet. (Don’t take care of the non-free part if you don’t need it).

I took a look at CMake GUI, there is no configuration errors…
I have also had a look at, and tried to install the github version non-succesfully…

Looking at line 64 of file /usr/local/cuda-8.0/include/cuda_gl_interop.h, it complains because GL_VERSION is not set.
This should be set by GL header (such as GL/gl.h) that should be included before including this file.

Yes, well in /usr/local/cuda-8.0/include/cuda_gl_interop.h, the error is due to this snippet of code:

#if defined(__arm__) || defined(__aarch64__)
#ifndef GL_VERSION
#error Please include the appropriate gl headers before including cuda_gl_interop.h
#include <GL/gl.h>

In the case of the TX1, aarch64 would be defined, and <GL/gl.h> wouldn’t be included, therefore I would suspect that GL_VERSION would be defined elsewhere, either in the included files “builtin_types.h”, “host_defines.h” or possibly in the project(?).

As far as I can find, no GL_VERSION is defined in any of the header files or their includes…

My CMake output regarding OpenGL is:

--   GUI: 
--     QT:                          NO
--     GTK+ 2.x:                    YES (ver 2.24.30)
--     GThread :                    YES (ver 2.48.1)
--     GtkGlExt:                    YES (ver 1.2.0)
--     OpenGL support:              YES (/usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/
--     VTK support:                 NO

Which seems to be correct when comparing to others successful builds. When I check the advanced setting in CMake GUI, no GL_VERSION entry is found, and the OpenGL related info is (except what is seen above):

OPENGL_INCLUDE_DIR : /usr/include

It seems that the xmesa is not needed to build OpenCV according to a quick google search.
The only definition of GL_VERSION I can find is in gl.h.

At this point, I’m starting to have doubts about compiling OpenCV with OpenGL, so I might just skip OpenGL support (see regarding the WITH_OPENGL=ON flag)…

Ok, so I have now compiled and installed OpenCV successfully without OpenGL!

Here is what I did:
Used these two guides - &

Modified “opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp” by replacing

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)


#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)  || (CUDART_VERSION >= 8000)

used this CMake command:


Compiled and installed!

Thanks for all the help guys, maybe I’ll return to try to get OpenGL to work some time later.