# can't build OpenCV 2.3.1



## hondo (Dec 16, 2011)

Hello,

I'm currently working with opencv and can't build opencv 2.3.1. I've searched the web, but it didn't help at all. The prerequisite libraries are installed, I've also updated the ports tree. 

`uname -a`

```
FreeBSD  8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     
[email]root@almeida.cse.buffalo.edu[/email]:/usr/obj/usr/src/sys/GENERIC  i386
```

`gcc -v`

```
gcc version 4.2.1 20070719
```

Any help is welcome.

greetz

hondo


```
[ 29%] Built target opencv_calib3d
Linking CXX executable ../../bin/opencv_test_calib3d
CMakeFiles/opencv_test_features2d.dir/test/test_features2d.o(.text._ZN55Features2d_DescriptorMatcher_FlannBased_regression_Test8TestBodyEv+0x21):
 In function `Features2d_DescriptorMatcher_FlannBased_regression_Test::TestBody()':
: undefined reference to `cv::flann::KDTreeIndexParams::KDTreeIndexParams(int)'
CMakeFiles/opencv_test_features2d.dir/test/test_features2d.o(.text._ZN55Features2d_DescriptorMatcher_FlannBased_regression_Test8TestBodyEv+0x71):
 In function `Features2d_DescriptorMatcher_FlannBased_regression_Test::TestBody()':
: undefined reference to `cv::flann::SearchParams::SearchParams(int, float, bool)'


Stop in /usr/ports/graphics/opencv.
*** Error code 1

Stop in /usr/ports/graphics/opencv.
[root@ /usr/ports/graphics/opencv]#
```


----------



## SirDice (Dec 16, 2011)

Handbook: Chapter 5 Installing Applications: Packages and Ports


----------



## rianav (Dec 30, 2011)

*Any luck?*

Hey,
Did you get it to build? Mine fails with:


```
[ 22%] Building CXX object modules/highgui/CMakeFiles/opencv_test_highgui.dir/test/test_ffmpeg.o
/usr/ports/graphics/opencv/work/OpenCV-2.3.1/modules/highgui/test/test_ffmpeg.cpp: In member function 'virtual void
 CV_FFmpegWriteSequenceImageTest::run(int)':
/usr/ports/graphics/opencv/work/OpenCV-2.3.1/modules/highgui/test/test_ffmpeg.cpp:125:10: warning: variable 'frame_s' set but not used
 [-Wunused-but-set-variable]
Linking CXX executable ../../bin/opencv_test_highgui
/usr/local/bin/ld: CMakeFiles/opencv_test_highgui.dir/test/test_drawing.o: undefined reference to symbol 'cv::rectangle(cv::Mat&,
 cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)'
/usr/local/bin/ld: note: 'cv::rectangle(cv::Mat&, cv::Point_<int>, cv::Point_<int>, cv::Scalar_<double> const&, int, int, int)' is defined in
 DSO /usr/local/lib/libopencv_core.so.2 so try adding it to the linker command line
/usr/local/lib/libopencv_core.so.2: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
*** Error code 1
1 error
*** Error code 2
[ 22%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/matchers.o
[ 22%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/descriptors.o
[ 23%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/evaluation.o
[ 23%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/orb.o
[ 23%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/blobdetector.o
[ 23%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/draw.o
[ 24%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/stardetector.o
[ 24%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/detectors.o
[ 24%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/bagofwords.o
[ 24%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/oneway.o
[ 25%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/dynamic.o
[ 25%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/brief.o
[ 25%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/sift.o
/usr/ports/graphics/opencv/work/OpenCV-2.3.1/modules/features2d/src/sift.cpp: In function 'double dominant_ori(double*, int)':
/usr/ports/graphics/opencv/work/OpenCV-2.3.1/modules/features2d/src/sift.cpp:921:7: warning: variable 'maxbin' set but not used
 [-Wunused-but-set-variable]
[ 25%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/mser.o
[ 26%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/keypoint.o
[ 26%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/planardetect.o
[ 26%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/calonder.o
Linking CXX shared library ../../lib/libopencv_features2d.so
[ 26%] Built target opencv_features2d
1 error
*** Error code 2
1 error
*** Error code 1

Stop in /usr/ports/graphics/opencv.
*** Error code 1
```


----------



## aleks_true (Mar 2, 2012)

I had the same problem and solved it.
When I typed:
[cmd=]pkg_info | grep opencv[/cmd]
I saw, that opencv-core have already installed, but opencv - not installed. Then I upgraded opencv-core by:
[cmd=]sudo portupgrade[/cmd]
or
[cmd=]make deinstall && make install[/cmd] (in port directory for opencv-core)

After that:
[cmd=]sudo make clean[/cmd]
And then tried to install opencv again.


----------

