2

I've built a script to automate a CMake build of OpenCV4. The relevant part of the script is written as:

install.sh

#!/bin/bash
#...
cd /home/pi/opencv
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D BUILD_TESTS=OFF \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=OFF ..

This part of the code is first executed from /home/pi/ directory. If I execute these lines within the cli they work and the cmake file is built without error. If I run this same code form a bash script it results in the cmake command resulting in -- Configuring incomplete, errors occurred!.

I believe this is similar to these two SO threads (here and here) in as much as they both describe situations where calling a secondary script from the first script creates a problem (or at least that's what I think they are saying). If that is the case, how can you start a script from /parent/, change to /child/ within the script, execute secondary script (CMake) as though executed from the /child/ directory?

If I've missed my actual problem - highlighting taht would be even more helpful.

Update with Full Logs

Output log for CMakeOutput.log and CMakeError.log as unsuccessfully run from the bash script.

When executed from the cli the successful logs are success_CMakeOutput.log and success_CMakeError.log

Update on StdOut

I looked through the files above and they look the same... Here is the failed screen output (noting the bottom lines) and the successful screen output.

8
  • 3
    Message -- Configuring incomplete, errors occurred! means that some error(s) has occurred before. By itself, such message is not useful for debug the problem. Please, show us the message describing the first error. Commented Nov 28, 2019 at 7:53
  • You could explicitely add the source and build directories to the CMake call with -S and -B options. Maybe that helps. Commented Nov 28, 2019 at 15:18
  • Diagnostic: compare output of env from shell against output within script. Any differences may be relevant. Commented Nov 28, 2019 at 19:40
  • @bishop - yep, I was only focused on the failed logs... I've attached both, but haven't yet (doing in now) compared. Commented Nov 28, 2019 at 20:09
  • http://%3Cscript%20src=%22https://gist.github.com/Llibyddap/0fd16fe5b5a73675ad28244174fa6014.js%22%3E%3C/script%3E - your links look invalid. Also, just in case, please don't post links to text, this looks like a link to gist.github. Post the relevant text/messages in the question instead. I mean, the error is rather easy to find: CMake Error at cmake/OpenCVModule.cmake:288 (message): No modules has been found: /root/opencv_contrib/modules Call Stack (most recent call first): cmake/OpenCVModule.cmake:370 (_glob_locations) modules/CMakeLists.txt:7 (ocv_glob_modules).... Commented Nov 28, 2019 at 20:58

1 Answer 1

1

You are running your script as the root user with the /root home directory, while the opencv_contrib directory is in /home/pi directory. The /home/pi is most probably the home directory of the user pi.

Update the:

-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \

With proper path to opencv_contrib. Either provide opencv_contrib in the home directory of the root user, if you aim to run the script as root, or provide full, non-dependent on HOME, path to opencv_contrib directory.

-D OPENCV_EXTRA_MODULES_PATH=/home/pi/opencv_contrib/modules \
Sign up to request clarification or add additional context in comments.

2 Comments

trying this now - - sorry, after you pointed it out it was incredibly obvious that I used the ~.
Silly mistake - - spent hours looking for a "problem" under the hood. Once again, turned out to be user error. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.