Building OpenCV 3.1 on Ubuntu 16.04 fails (undefined references) - opencv

I am trying to install OpenCV3.1 on my Ubuntu 16.04 for development in QT5. Sadly, building it from source always errors out due to undefined references (see below).
I used the following:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D BUILD_TIFF=ON -D WITH_VTK=ON..
And it works fine. But building it always produces this error
../../lib/libopencv_viz.so.3.1.0: undefined reference to `vtkSTLReader::New()'
../../lib/libopencv_viz.so.3.1.0: undefined reference to `vtkOBJReader::New()'
collect2: error: ld returned 1 exit status
modules/viz/CMakeFiles/opencv_test_viz.dir/build.make:232: recipe for target 'bin/opencv_test_viz' failed
make[2]: *** [bin/opencv_test_viz] Error 1
CMakeFiles/Makefile2:3358: recipe for target 'modules/viz/CMakeFiles/opencv_test_viz.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/opencv_test_viz.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Of course I googled and tried everything I found. Tried several different cmake flags (or rather, without any), tried reinstalling libvtk5-dev and also tried libvtk6-dev and even build vtk7.1 from source, since I am assuming something is missing from there.
I also tried adding the opencv_contrib via
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D BUILD_TIFF=ON -D WITH_VTK=ON -D BUILD_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/user/opencv/opencv-3.1.0/opencv_contrib/modules ..
But that already produced the following error
CMake Error at opencv_contrib/modules/text/CMakeLists.txt:22 (ocv_add_testdata): `Unknown CMake command "ocv_add_testdata".
Also please note that I did upgrade/update all the packages that are listed here and here
So basically after two days randomly trying all the possible solutions I could find via google, I am now asking here.
Hopefully someone knows how to fix this, thank you!
Edit: I only get these problems with OpenCV3.1. I do have a working OpenCV 2.4.13

Same happend with me. It was working and suddenly I got the same error. I re-pulled OpenCV 3.1 and it worked again.
It seems that the guys updated something both in Extra Modules and in OpenCV and you have just pull the extra modules.

For the second part, it looks like someone messed up the opencv_contrib/modules/text/CMakeLists.txt
Just edit this file and remove the lines at the end:
ocv_add_testdata(samples/ contrib/text
FILES_MATCHING PATTERN "*.xml" PATTERN "*.xml.gz" REGEX "scenetext[0-9]+.jpg"
COMPONENT "tests"
)

just switch opencv_contrib repository to 3.1.0 tag after clone.
git checkout 3.1.0
and try to build again.

First, make sure you have successfully built and installed vtk on your system;
Then,by using command "locate STLReader" or "locate vtkOBJReader" to ensure "vtkOBJReader" or "STLReader" libs are found in some specific directories. If vtkOBJReader or STLReader related files are found. It means that vtk has changed its structure in the new version, e.g. move vtkOBJReader into a sub library vtkIOGeometry, so you have to tell cmake to find vtkIOGeometry if you want to use that class.
Last, modify opencv3/cmake/OpenCVDetectVTK.cmake, for every find_package(VTK QUIET COMPONENTS ... add an entry vtkIOGeometry.
Success!

Related

Imagemagick yasm singularity build fails

I am attempting to convert the docker file for :
https://hub.docker.com/r/dpokidov/imagemagick/
to singularity. The docker builds fine in docker. In my singularity def file the following line fails with the error.
yasm cmake
libde265-0 libde265-dev libjpeg62-turbo libjpeg62-turbo-dev x265 libx265-dev libtool
libpng16-16 libpng-dev libjpeg62-turbo libjpeg62-turbo-dev libwebp6 libwebp-dev libgomp1 libwebpmux3 libwebpdemux2 ghostscript
yasm cmake
yasm: warning: can open only one input file, only the last file will be processed
yasm: file name already has no extension: output will be in `yasm.out'
yasm: FATAL: Could not open input file
FATAL: failed to execute %post proc: exit status 1
FATAL: While performing build: while running engine: exit status 255
When I cut the list of names to 1 it still fails to open the file.
I can't find a reference for this with singularity.
The docker build looks the same and works fine. So I assume its a singularity thing?
Seems like something with the assembler and the build environment being a bit different than it's expecting.
Is there a reason you're creating a definition file from scratch rather than using the docker image directly? singularity pull docker://dpokidov/imagemagick should give you what you need.
If you want to make further changes to the image, you can also use:
Bootstrap: docker
From: dpokidov/imagemagick
%post
# custom stuff here

8th wall web app setup child compilation failed

I am new to 8th wall. I have cloned 8th wall web from git and executed below steps properly
# cd <directory_where_you_saved_sample_project_files>
# cd serve
# npm install
# cd ..
# ./serve/bin/serve -d <sample_project_location>
but on execution of last step which is for ex.
./serve/bin/serve -n -d gettingstarted/xraframe/ -p 7777
I am getting below errors
Failed to compile.
Error: Child compilation failed: Entry module not found: Error:
Can't resolve
'C:\8thWall_Project\web\serve\bin\gettingstarted\xraframe"
\index.html' in 'C:\8thWall_Project\web\serve': Error: Can't resolve
'C:\8thWall_Project\web\serve\bin\gettingstarted\xraframe"
\index.html' in 'C:\8thWall_Project\web\serve'
compiler.js:79 childCompiler.runAsChild
[serve]/[html-webpack-plugin]/lib/compiler.js:79:16
Compiler.js:306 compile
[serve]/[webpack]/lib/Compiler.js:306:11
Compiler.js:631 hooks.afterCompile.callAsync.err
[serve]/[webpack]/lib/Compiler.js:631:15
Hook.js:154 AsyncSeriesHook.lazyCompileHook
[serve]/[tapable]/lib/Hook.js:154:20
Compiler.js:628 compilation.seal.err
[serve]/[webpack]/lib/Compiler.js:628:31
Hook.js:154 AsyncSeriesHook.lazyCompileHook
[serve]/[tapable]/lib/Hook.js:154:20
Compilation.js:1325 hooks.optimizeAssets.callAsync.err
[serve]/[webpack]/lib/Compilation.js:1325:35
Any idea or pointers what is missing?
Thanks
I don't know why, but bat file don't want to be opened by path. Just go to the serve\bin directory and launch bat from here, like that:
7777 is unnecessary. problem was, that it can't find path to your xraframe
project, as you are in another directory, so you have to go tow directories up in ypur path for xraframe
It seems as if you're attempting this on a Windows computer. The serve process for Windows is slightly different than on macOS.
Instead of the normal serve script, use the serve.bat executable.
serve\bin\serve.bat -n -d gettingstarted\xraframe -p 7777
https://docs.8thwall.com/web/#locally-from-windows

Compiling OpenCV with VTK support for Open Detection

I'm trying to install OpenDetection on Ubuntu 16.04.
I have installed all the dependencies according to here except OpenCV.
This is the CMake command I used for OpenCV:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_VTK=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -DOPENCV_EXTRA_MODULES_PATH=/home/tiestu/Documents/GitRepository/OpenCV3/opencv_contrib/modules /home/tiestu/Documents/GitRepository/OpenCV3/opencv
But when I try to make OpenCV, I receive this error which I believe has something to do with VTK!
I have configured VTK using latest prebuilt binary version of cmake with the default settings, as per installation instructions. but this error says:
vtkGenericDataArrayLookupHelper.h:72:23: error: ‘nullptr’ was not declared in this scope
The full error/warning section of the build output is:
In file included from /usr/local/include/vtk-7.1/vtkGenericDataArray.h:72:0,
from /usr/local/include/vtk-7.1/vtkAOSDataArrayTemplate.h:35,
from /usr/local/include/vtk-7.1/vtkIntArray.h:33,
from /usr/local/include/vtk-7.1/vtkCellTypes.h:42,
from /usr/local/include/vtk-7.1/vtkPolyData.h:64,
from /usr/local/include/vtk-7.1/vtkPolyDataAlgorithm.h:36,
from /usr/local/include/vtk-7.1/vtkAppendPolyData.h:35,
from /home/tiestu/Documents/GitRepository/OpenCV3/opencv/modules/viz/src/precomp.hpp:56,
from /home/tiestu/Documents/GitRepository/OpenCV3/opencv/release/modules/viz/opencv_viz_pch_dephelp.cxx:1:
/usr/local/include/vtk-7.1/vtkGenericDataArrayLookupHelper.h:72:5: warning: identifier ‘nullptr’ is a keyword in C++11 [-Wc++0x-compat]
: AssociatedArray{nullptr}, SortedArray(nullptr),
^
/usr/local/include/vtk-7.1/vtkGenericDataArrayLookupHelper.h: In constructor ‘vtkGenericDataArrayLookupHelper<ArrayTypeT>::vtkGenericDataArrayLookupHelper()’:
/usr/local/include/vtk-7.1/vtkGenericDataArrayLookupHelper.h:72:22: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
: AssociatedArray{nullptr}, SortedArray(nullptr),
^
/usr/local/include/vtk-7.1/vtkGenericDataArrayLookupHelper.h:72:23: error: ‘nullptr’ was not declared in this scope
: AssociatedArray{nullptr}, SortedArray(nullptr),
^
/usr/local/include/vtk-7.1/vtkGenericDataArrayLookupHelper.h:73:15: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
FirstValue{nullptr}, SortedArraySize{0}
^
/usr/local/include/vtk-7.1/vtkGenericDataArrayLookupHelper.h:73:41: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
FirstValue{nullptr}, SortedArraySize{0}
^
modules/viz/CMakeFiles/opencv_viz_pch_dephelp.dir/build.make:62: recipe for target 'modules/viz/CMakeFiles/opencv_viz_pch_dephelp.dir/opencv_viz_pch_dephelp.cxx.o' failed
make[2]: *** [modules/viz/CMakeFiles/opencv_viz_pch_dephelp.dir/opencv_viz_pch_dephelp.cxx.o] Error 1
CMakeFiles/Makefile2:6005: recipe for target 'modules/viz/CMakeFiles/opencv_viz_pch_dephelp.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/opencv_viz_pch_dephelp.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
Does it matter what version of compiler (11 or 0x) I've used? If so what version should I use?
You need to use a compiler that supports the version of OpenCV that you are using, and the version of the C++ language that it uses, which from your error and warning diagnostic messages, looks be at least C++11.
You can read the documentation for the compiler version you have to see what C++ language versions it supports. There's also a support information table on cppreference.com.
It's interesting that you get such errors and warnings at all. Libraries should be able to tell CMake in its CMake configuration what C++ language version it uses in its source files, and CMake would keep track of that requirement to make sure the correct compiler flags get used wherever needed. See the target_compile_features() command for more info on that.

ERROR while code coverage report using lcov

I am trying to run coverage on my project, after updating to Ubuntu 16.04.
I get
Deleted 665 files
Writing data to coverage.info.cleaned
lcov: ERROR: cannot write to coverage.info.cleaned!
CMakeFiles/coverage.dir/build.make:57: recipe for target 'CMakeFiles/coverage' failed
make[3]: *** [CMakeFiles/coverage] Error 13
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/coverage.dir/all' failed
make[2]: *** [CMakeFiles/coverage.dir/all] Error 2
CMakeFiles/Makefile2:74: recipe for target 'CMakeFiles/coverage.dir/rule' failed
make[1]: *** [CMakeFiles/coverage.dir/rule] Error 2
Makefile:129: recipe for target 'coverage' failed
make: *** [coverage] Error 2
enter code here
Before the update I had no problem running the coverage
Does it help if you use absolute paths instead of relative paths when passing files to lcov?
I ran into a similiar problem where lcov also failed to write the file.
Not sure if it is a bug in lcov, but the problem was that it got confused with relative paths:
lcov -a test_fast_cxxtest_gcov__base.info -a test_fast_cxxtest_gcov__test.info \
-o test_fast_cxxtest_gcov__total.info
Combining tracefiles.
Reading tracefile test_fast_cxxtest_gcov__base.info
Reading tracefile test_fast_cxxtest_gcov__test.info
lcov: WARNING: function data mismatch at /home/phil/ghost/constants.h:1862
Writing data to test_fast_cxxtest_gcov__total.info
lcov: ERROR: cannot write to test_fast_cxxtest_gcov__total.info!
Running it with strace revealed that it executes chdir("/") on several locations, which changes the working directory to /. That explains why it cannot write the file.
One workaround is to use absolute paths. For instance, if you are using GNU make, you can use the abspath command:
lcov -a $(abspath test_fast_cxxtest_gcov__base.info) \
-a $(abspath test_fast_cxxtest_gcov__test.info) \
-o $(abspath test_fast_cxxtest_gcov__total.info)
After that change, it was finally able to write the file.
(Other options like trying to set the directories using the --base-directory or --directory option did not have an effect, as far as I saw.
The version of lcov that I tested with is 1.12.)
The problem is not limited to Ubuntu, as I ran into it on Arch Linux. It could be a regression introduced in 1.12, however, so I reported it (see issue #77630).
Update: Lcov is not part of GCC, so my original bug report was closed, but I got an answer from the Lcov mailing list. The problem is already fixed in commit 632c25. Users of Arch Linux based distros can try the latest snapshot with aur/lcov-git.

make OpenCV in CentOS(Linux)

I try to install openCV 3.1.0 following this tutorial
http://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html#gsc.tab=0
I cmake it with this command:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/path/to/install /home/path/to/source
which could work. And then I just make, following errors appear:
Building CXX object modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_tiff.cpp.o
opencv/modules/imgcodecs/src/grfmt_tiff.cpp:61:18: error: tiff.h: No such file or directory
opencv/modules/imgcodecs/src/grfmt_tiff.cpp:62:20: error: tiffio.h: No such file or directory
opencv/modules/imgcodecs/src/grfmt_tiff.cpp: In constructor ‘cv::TiffDecoder::TiffDecoder()’:
Following many similar errors, anyone has any suggestion?

Resources