3

I am using cmake-gui trying to build opencv but get this error:

CMake Error at cmake/OpenCVGenConfig.cmake:134 (math):
  math cannot parse the expression: "8 * ": syntax error, unexpected $end,
  expecting exp_OPENPARENT or exp_NUMBER (4)
Call Stack (most recent call first):
  CMakeLists.txt:649 (include)

This is my first experience with cmake so I am not sure where to turn. I have looked at the OpenCVGenConfig.cmake file but I am clueless about its syntax. I blew away everything, downloaded the opencv tarball again, but still get the same error. So it does not appear that it is a typo/error in the OpenCVGenConfig.cmake file but in the processing of the "math" command. I can not seem to find anything relating to a "math" command in the Cmake documentation.

Any ideas?

-Andres

1
  • Which version of CMake are you using? Ensure you are running the most recent (currently 2.8) to build the current release of OpenCV. Although the docs say an earlier version is ok, some errors can crop up on <2.8. Commented May 12, 2012 at 1:45

1 Answer 1

9

It looks like the line in question is

  math(EXPR SIZEOF_VOID_P_BITS "8 * ${CMAKE_SIZEOF_VOID_P}")

The problem appears to be that ${CMAKE_SIZEOF_VOID_P} is unset when it should indicate the size of a pointer in bytes. It should get set during the invocation of the project command near the start of the top-level CMakeLists.txt.

I'm not sure why it's not being set, it may even be a bug in CMake. You could try using the latest version of CMake (currently 2.8.8) if you're not already. Also, running CMake from the command line may make a difference (it shouldn't, but you never know).

If this doesn't help, your best bet is to ask for advice on the CMake mailing list.

As an absolute last resort, you could set the appropriate value for CMAKE_SIZEOF_VOID_P on your machine by adding

  if(NOT CMAKE_SIZEOF_VOID_P)
    set(CMAKE_SIZEOF_VOID_P 4)  # replace 4 with 8 for 64-bit machine
  endif()

to cmake/OpenCVGenConfig.cmake just before line 134 where the math call is made. This is a horrible hack and I certainly don't recommend it, but it could let you build OpenCV while seeking a proper answer on the mailing list.


You can get info on the math command by running

cmake --help-command math

and on CMAKE_SIZEOF_VOID_P by running

cmake --help-variable CMAKE_SIZEOF_VOID_P
Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your response and suggestions. I will give all of them a try.

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.