"cannot find -lopencv_nonfree"

Now I configure my TX1 by Jetpack 2.3.1,and install the opencv 3.1 and caffe,then when I want to test the samples of opencv 3.1(opencv-3.1.0/samples/gpu/hog.cpp),it occured a err:
I learn from http://elinux.org/Jetson/Tutorials/Full_Body_Detection
And when I run the command:

g++ hog.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o hog

It occurs that:

ubuntu@tegra-ubuntu:~/Downloads/opencv-3.1.0/samples/gpu$ g++ hog.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_video -lopencv_videostab -o hog
/usr/bin/ld: cannot find -lopencv_nonfree
collect2: error: ld returned 1 exit status

I tried to run follow command ro install it,but failed

sudo apt-get update
sudo add-apt-repository --yes ppa:xqms/opencv-nonfree
sudo apt-get update
sudo apt-get install libopencv-nonfree-dev

How should I do it?Anyone can help me?

Have you built opencv-3.1 from source ?
In such case the non-free part is not enabled by default.
You should reconfigure it (with cmake-gui is the easiest way), enable non-free options, re-compile and install again.

Thanks very much!
But could you tell more detailed please? I am a beginner. I just don’t know which is the "cmake-gui "

Thank you!!

cmake is a program for handling various build configurations for the same source code (such as different options, target platforms…).
It is used for building OpenCV.

cmake-gui is a graphical frontend for cmake. It is based on qt. You can install it with :

sudo apt-get install cmake-qt-gui

Then from a shell you can launch it with :


Then select the source folder (say …/opencv-3.1/src) where you have downloaded opencv-3.1 sources, and the build folder (say …/opencv-3.1/build).

Click on configure. Look for the options and enable opencv non-free.
Click again on configure and check for any errors (in red).

If ok, click on generate. This will create makefiles in your build directory.

Then, go to build directory in a shell, and type


to start building. It may take some time.

When everything is completed, install it with:

sudo make install