UBUNTU 16.04 Opencv 3.3.1 fatal error: cvconfig.h: No such file or directory
I am trying to compile & run the ukf test in the following directory:
~/opencv_contrib/modules/tracking/test/test_ukf.cpp
when I try to compile it using ( g++ test_ukf.cpp ) command I get:
In file included from test_ukf.cpp:42:0: test_precomp.hpp:13:26: fatal error: opencv2/ts.hpp: No such file or directory compilation terminated.
Then I specify the include directory where ts.hpp exists using : g++ -o app -I/home/akde/opencv/modules/ts/include/ test_ukf.cpp But this time I get
In file included from test_precomp.hpp:13:0, from test_ukf.cpp:42: /home/akde/opencv/modules/ts/include/opencv2/ts.hpp:22:22:> fatal error: cvconfig.h: No such file> or directory compilation terminated.
Finally I searched for the cvconfig.h and found it in 2 places:
1-/home/akde/opencv/build/opencv2/cvconfig.h
2-/home/akde/opencv/build/cvconfig.h
I specified the locations and compiled using:
g++ -o app -I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build/opencv2 test_ukf.cpp
and
g++ -o app -I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build test_ukf.cpp
and
g++ test_ukf.cpp -o app "pkg-config --cflags --libs opencv" -I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build
This time I get a gigantic error:
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function
_start': (.text+0x20): undefined reference to
main' /tmp/cc1Bc7jy.o: In functionUKF_br_landing_point_Test::TestBody()': test_ukf.cpp:(.text+0x29): undefined reference to
cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)' test_ukf.cpp:(.text+0x42): undefined reference tocv::ipp::setIppStatus(int, char const*, char const*, int)' test_ukf.cpp:(.text+0x47): undefined reference to
cv::theRNG()' test_ukf.cpp:(.text+0x51): undefined reference tocvtest::param_seed' test_ukf.cpp:(.text+0x70): undefined reference to
cvtest::checkIppStatus()' /tmp/cc1Bc7jy.o: In functionUKF_br_landing_point_Test::Body()': test_ukf.cpp:(.text+0x1cd): undefined reference to
cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x2cf): undefined reference tocv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x342): undefined reference to
cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x381): undefined reference tocv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x414): undefined reference to
cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x487): undefined reference tocv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x5ef): undefined reference to
cv::Mat::eye(int, int, int)' test_ukf.cpp:(.text+0x621): undefined reference tocv::operator*(double, cv::MatExpr const&)' test_ukf.cpp:(.text+0x763): undefined reference to
cv::tracking::UnscentedKalmanFilterParams::UnscentedKalmanFilterParams(int, int, int, double, double, cv::Ptr<cv::tracking::ukfsystemmodel>, int)' test_ukf.cpp:(.text+0x8cc): undefined reference tocv::tracking::createUnscentedKalmanFilter(cv::tracking::UnscentedKalmanFilterParams const&)' test_ukf.cpp:(.text+0x910): undefined reference to
cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x9fc): undefined reference tocv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0xa49): undefined reference to
cv::operator ...
(backticks) around the pkg-config part, not
" `-lopencv_ts
and set up the correct-L
flag for this (it is not installed to your usr/loca/lib folderthx for swift reply. - it should be (backticks) around the pkg-config part, not "
**: they were
. I changed ` into " just to make them more visible in the question. - **the tests are usually built along with the opencv libs, with BUILD_TESTS=ON. (it's not really expected, that you do that later, manually) : to be honest I did not understand what should I do about this bullet. Should I rebuild the opencv with cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_TESTS=ON ..? - you also need to link to -lopencv_ts and set up the correct -L flag for this (it is not installed to your usr/loca/lib folder : How can I do that? I searched for opencv_ts and find only 3 files namely opencv_ts_RELEASE.gch, opencv_ts_pch_dephelp.cxx.o and opencv_ts_pch_dephelp.cxx - compiling main results in errorthat would be the most easy way.
did you have at least
BUILD_opencv_ts=ON
before ? else it won't build the opencv_ts lib. there should be alibopencv_ts.a
inopencv/build/lib
and you need to link against thatjust as u said the "libopencv_ts.a" exists in ~/opencv/build/lib so I build using the following
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/akde/opencv_contrib/modules -D BUILD_EXAMPLES=ON -D BUILD_opencv_python2=OFF -D WITH_FFMPEG=1 -D WITH_CUDA=ON -D CUDA_GENERATION=Kepler -D_TESTS=ON ..
then sudo make -j8 sudo make install
Then tried to compile with g++ test_main.cpp -o app
pkg-config --cflags --libs opencv
-I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build I got the same errors.Then I try to link /home/akde/opencv/build/lib/ where the opencv_ts exists with the following
sudo ln -s /home/akde/opencv/build/lib/opencv_ts /usr/local/bin
sudo ln -s /home/akde/opencv/build/lib/ /usr/local/bin
and tried to compile with *g++ test_main.cpp -o app
pkg-config --cflags --libs opencv
-I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build -L/home/akde/opencv/build/lib/opencv_ts * but again the same errorit should be:
(and again, this lib is neither in the pkg list, nor does it get installed to /usr/local/lib)
ts.cpp is in /home/akde/opencv/modules/ts/src/
in test_precomp.hpp, when change the #include "opencv2/ts.hpp" line to #include "/home/akde/opencv/modules/ts/src/ts.hpp" I still get the test_precomp.hpp:14:51: fatal error: /home/akde/opencv/modules/ts/src/ts.hpp: No such file or directory compilation terminated. error. File that is looked for is exactly in the mentioned path, but still the compiler cannot see that. Why is it?
g++ test_main.cpp -o app
pkg-config --cflags --libs opencv
-L/home/akde/opencv/build/lib -lopencv_tsIn file included from test_main.cpp:1:0: test_precomp.hpp:13:26: fatal error: opencv2/ts.hpp: No such file or directory compilation terminated.
You can try this method : copy header files from opencv-module to you opencv-installation-prefix/include/.. directory For example : in my case ts.hpp goes into opencv2/ and all other headers into opencv2/ts/ . So you can do this all by yourself