Unable to build OpenCV2 since lots of Object-C error - opencv

Guys
I'm trying to build OpenCV2 on OS X 10.8.3 under this official installation guide.
The configure step works fine:
cmake -D:CMAKE_BUILD_TYPE=RELEASE ..
But when i build it with make:
make -j 8
There turns out lots of Object-C errors like this:
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:260: error: expected ';' before '__attribute__'
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:261: error: expected ':' before '(' token
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:261: error: expected type-specifier before '(' token
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:261: error: expected ')' before '(' token
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:261: error: expected identifier before '(' token
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:261: error: expected ';' before '(' token
/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:262: error: expected ';' before '__attribute__'
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:52,
from /System/Library/Frameworks/QTKit.framework/Headers/QTError.h:8,
from /System/Library/Frameworks/QTKit.framework/Headers/QTKit.h:11,
from /Users/kuankuan/Desktop/RoysData/Workspace/opencv/opencv-2.4.5/modules/highgui/src/cap_qtkit.mm:34:
/System/Library/Frameworks/Foundation.framework/Headers/NSPointerArray.h:57: error: expected ';' before '__attribute__'
/System/Library/Frameworks/Foundation.framework/Headers/NSPointerArray.h:58: error: expected ';' before '__attribute__'
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:54,
from /System/Library/Frameworks/QTKit.framework/Headers/QTError.h:8,
from /System/Library/Frameworks/QTKit.framework/Headers/QTKit.h:11,
from /Users/kuankuan/Desktop/RoysData/Workspace/opencv/opencv-2.4.5/modules/highgui/src/cap_qtkit.mm:34:
/System/Library/Frameworks/Foundation.framework/Headers/NSPort.h:68: error: expected constructor, destructor, or type conversion before '-' token[ 42%]
/System/Library/Frameworks/Foundation.framework/Headers/NSPort.h:115: error: expected constructor, destructor, or type conversion before '-' token
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:57,
I have installed XCode and xcode command line tool. How can i deal with this issue ? i'm going to use opencv under c++.
Many thanks !

Related

What is the missing binary operator before token "(" 44 | #if __GLIBC_PREREQ(2,15) GNU?

I am getting the above error.
I work in cygwin 3.15 under windows 10. glibc 2.30 version included.
while compiling opencv project with aarch64-unknown-linux-gnu-g++ compiler with.
a snippet of error is
.... from constants.cpp:1:
/home/user/x-tools/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/include/c++/9.2.0/aarch64-unknown-linux-gnu/bits/os_defines.h:44:19: error: missing binary operator before token "("
44 | #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
where as simple c++ program is compiled without any error for the same target.

wkhtmltopdf_binary_gem : Syntax error: word unexpected (expecting ")")

In production server (ubuntu 14.04) getting this error while PDF download
referred link and tried
https://gist.github.com/brunogaspar/bd89079245923c04be6b0f92af431c10
$ wkhtmltopdf http://www.google.com google.pdf
/usr/local/rvm/gems/ruby-2.5.1/gems/wkhtmltopdf-binary-0.12.4/bin/wkhtmltopdf_linux_x86: 1: /usr/local/rvm/gems/ruby-2.5.1/gems/wkhtmltopdf-binary-0.12.4/bin/wkhtmltopdf_linux_x86: Syntax error: word unexpected (expecting ")")
any help?

Error while build ffmpeg for iOS

I'm trying to build fmmpeg for iOS with the following config:
./configure --prefix=build/armv7 --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avutil --enable-avresample --enable-cross-compile --sysroot="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk" --target-os=darwin --cc=gcc --extra-cflags="-arch armv7 -mfpu=neon -miphoneos-version-min=6.0" --extra-ldflags="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -miphoneos-version-min=6.0" --arch=arm --cpu=cortex-a9 --enable-pic
when i try to make it i'm receiving the follow error:
AS libavcodec/arm/vc1dsp_neon.o
libavcodec/arm/vc1dsp_neon.S:751:10: error: unexpected token in argument list
ra .dn d28.i8
^
libavcodec/arm/vc1dsp_neon.S:752:10: error: unexpected token in argument list
rb .dn d29.i8
^
libavcodec/arm/vc1dsp_neon.S:753:10: error: unexpected token in argument list
rc .dn d30.i8
^
libavcodec/arm/vc1dsp_neon.S:754:10: error: unexpected token in argument list
rd .dn d31.i8
^
libavcodec/arm/vc1dsp_neon.S:757:14: error: invalid operand for instruction
vmov ra, #4
^
libavcodec/arm/vc1dsp_neon.S:758:14: error: invalid operand for instruction
vmov rb, #53
^
libavcodec/arm/vc1dsp_neon.S:759:14: error: invalid operand for instruction
vmov rc, #18
^
libavcodec/arm/vc1dsp_neon.S:760:14: error: invalid operand for instruction
vmov rd, #3
^
libavcodec/arm/vc1dsp_neon.S:864:10: error: unexpected token in argument list
ra .dn d28.i16
^
libavcodec/arm/vc1dsp_neon.S:865:10: error: unexpected token in argument list
rb .dn d29.i16
^
what could be the error?
Try adding the flags --disable-neon and --disable-armv5te.
BTW, the following set of flags does the trick for AMRv7:
'--arch=arm',
'--enable-pic',
"--extra-cflags='-arch armv7 -miphoneos-version-min=6.0'",
"--extra-ldflags='-arch armv7 -miphoneos-version-min=6.0'",
'--disable-neon',
'--enable-optimizations',
'--disable-debug',
'--disable-armv5te',
'--disable-armv6',
'--disable-armv6t2',
'--disable-ffmpeg',
'--disable-ffplay',
'--disable-ffserver',
'--disable-ffprobe',
'--disable-doc',
'--disable-bzlib',
'--target-os=darwin',
'--enable-cross-compile',
'--enable-version3',
Or, event better, you change the version of gas-preprocessor you have to the libAV maintained version: https://github.com/libav/gas-preprocessor
Hope this helps.

CMake how to remove the path from compile errors

When using cmake if there is a compile error the error is output with the entire path to the file containing the error. This path can be very long (see example below) so often it word wraps and makes it difficult to read.
Example Output:
/home/nick/projects/projectA/src/environment/base/terrain/base/TestFile.h:21:37: error: ‘TestFile’ does not name a type
/home/nick/projects/projectA/src/environment/base/terrain/base/TestFile.h:21:54: error: expected unqualified-id before ‘test’
/home/nick/projects/projectA/src/environment/base/terrain/base/TestFile.h:21:54: error: expected ‘)’ before ‘test’
Is there a way to remove the path from the error?
Something like this:
TestFile.h:21:37: error: ‘TestFile’ does not name a type
TestFile.h:21:54: error: expected unqualified-id before ‘test’
TestFile.h:21:54: error: expected ‘)’ before ‘test’
Thanks
I don't know if it is possible within cmake, but you can always redirect stderr to stdout and filter the output with a short sed script. At least the common project path can be filtered
make 2>&1 | sed 's/\/home\/nick\/projects\/projectA\/src\///g'

OpenCV install error: cvboost.cpp:1439: error: expected ';' before cvReleaseMat

Opencv Error:
I got the following error while installing OpenCV on Lucid.
81% ....
"cvboost.cpp:1439: error: expected ';' before cvReleaseMat"
SOLUTION:
edit cvboost.cpp and add semicolon on line:1438
SOLUTION:
edit cvboost.cpp and add semicolon on line:1438

Resources