UBUNTU 16.04 Opencv 3.3.1 fatal error: cvconfig.h: No such file or directory

asked 2018-08-09 02:47:50 -0600

burakakde gravatar image

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 tomain' /tmp/cc1Bc7jy.o: In function UKF_br_landing_point_Test::TestBody()': test_ukf.cpp:(.text+0x29): undefined reference tocv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)' test_ukf.cpp:(.text+0x42): undefined reference to cv::ipp::setIppStatus(int, char const*, char const*, int)' test_ukf.cpp:(.text+0x47): undefined reference tocv::theRNG()' test_ukf.cpp:(.text+0x51): undefined reference to cvtest::param_seed' test_ukf.cpp:(.text+0x70): undefined reference tocvtest::checkIppStatus()' /tmp/cc1Bc7jy.o: In function UKF_br_landing_point_Test::Body()': test_ukf.cpp:(.text+0x1cd): undefined reference tocv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x2cf): undefined reference to cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x342): undefined reference tocv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x381): undefined reference to cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x414): undefined reference tocv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x487): undefined reference to cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x5ef): undefined reference tocv::Mat::eye(int, int, int)' test_ukf.cpp:(.text+0x621): undefined reference to cv::operator*(double, cv::MatExpr const&)' test_ukf.cpp:(.text+0x763): undefined reference tocv::tracking::UnscentedKalmanFilterParams::UnscentedKalmanFilterParams(int, int, int, double, double, cv::Ptr<cv::tracking::ukfsystemmodel>, int)' test_ukf.cpp:(.text+0x8cc): undefined reference to cv::tracking::createUnscentedKalmanFilter(cv::tracking::UnscentedKalmanFilterParams const&)' test_ukf.cpp:(.text+0x910): undefined reference tocv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x9fc): undefined reference to cv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0xa49): undefined reference tocv::operator ...

(more)
edit retag flag offensive close merge delete

Comments

1
  • 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)
  • it should be (backticks) around the pkg-config part, not " `
  • you also need to compile test_main.cpp from there
  • 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
berak gravatar imageberak ( 2018-08-09 03:04:38 -0600 )edit

thx 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 error

burakakde gravatar imageburakakde ( 2018-08-09 04:00:26 -0600 )edit

Should I rebuild the opencv with cmake -D CMAKE_BUILD_TYPE=RELEASE -D_TESTS=ON ..?

that 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 a libopencv_ts.a in opencv/build/lib and you need to link against that

berak gravatar imageberak ( 2018-08-09 04:50:23 -0600 )edit

just 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

burakakde gravatar imageburakakde ( 2018-08-09 07:00:28 -0600 )edit

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 error

burakakde gravatar imageburakakde ( 2018-08-09 07:06:25 -0600 )edit

it should be:

-L/home/akde/opencv/build/lib -lopencv_ts

(and again, this lib is neither in the pkg list, nor does it get installed to /usr/local/lib)

berak gravatar imageberak ( 2018-08-09 07:11:19 -0600 )edit

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?

burakakde gravatar imageburakakde ( 2018-08-09 07:19:41 -0600 )edit

g++ test_main.cpp -o app pkg-config --cflags --libs opencv -L/home/akde/opencv/build/lib -lopencv_ts

In 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.

burakakde gravatar imageburakakde ( 2018-08-09 07:31:06 -0600 )edit

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

$ sudo mkdir -p /usr/local/include/opencv4/opencv2/ts

$ sudo cp /home/username/opencv-4.0.0-alpha/modules/ts/include/opencv2/ts/* /usr/local/include/opencv4/opencv2/ts/

$ sudo cp /home/username/opencv-4.0.0-alpha/modules/ts/include/opencv2/ts.hpp   /usr/local/include/opencv4/opencv2
saptami gravatar imagesaptami ( 2018-12-01 06:49:08 -0600 )edit