I'm trying to compile a project that uses opencv using xcode 4.5 on Mountain Lion 10.8, I followed closely the procedure on this link:
Compile OpenCV (2.3.1+) for OS X Lion / Mountain Lion with Xcode
This is the sequence that I have followed;
Installed opencv using ports: sudo port install opencv
configure.compiler = llvm-gcc-4.2
Opened Xcode and created a new project (command line app using c++).
Added the "/opt/local/lib/**" path to "Library search paths"
Added any libopencv_. Dylib to a new group
Added the "/opt/local/include/**" path to "Header search paths"
Every time I try to compile xcode fail with this error:
In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:46:
In file included from /opt/local/include/opencv2/core/core_c.h:47:
/opt/local/include/opencv2/core/types_c.h:322:17: error: use of undeclared identifier 'lrint'
return (int)lrint(value);
^
/opt/local/include/opencv2/core/types_c.h:742:5: error: use of undeclared identifier 'assert'
assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F );
^
/opt/local/include/opencv2/core/types_c.h:773:5: error: use of undeclared identifier 'assert'
assert( (unsigned)row < (unsigned)mat->rows &&
^
/opt/local/include/opencv2/core/types_c.h:780:9: error: use of undeclared identifier 'assert'
assert( type == CV_64FC1 );
^
/opt/local/include/opencv2/core/types_c.h:790:5: error: use of undeclared identifier 'assert'
assert( (unsigned)row < (unsigned)mat->rows &&
^
/opt/local/include/opencv2/core/types_c.h:797:9: error: use of undeclared identifier 'assert'
assert( type == CV_64FC1 );
^
In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:46:
/opt/local/include/opencv2/core/core_c.h:1118:5: error: use of undeclared identifier 'assert'
assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ );
^
In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:47:
In file included from /opt/local/include/opencv2/core/core.hpp:56:
In file included from /usr/include/c++/4.2.1/algorithm:64:
In file included from /usr/include/c++/4.2.1/bits/stl_algobase.h:70:
In file included from /usr/include/c++/4.2.1/iosfwd:44:
/usr/include/c++/4.2.1/bits/c++locale.h:76:5: error: use of undeclared identifier 'va_start'
va_start(__args, __fmt);
^
/usr/include/c++/4.2.1/bits/c++locale.h:84:5: error: use of undeclared identifier 'va_end'
va_end(__args);
^
/usr/include/c++/4.2.1/cstdarg:54:20: note: expanded from macro 'va_end'
#define va_end(ap) va_end (ap)
^
In file included from /Users/oliver/OpenCVHelloWorld/main.cpp:12:
In file included from /opt/local/include/opencv2/opencv.hpp:47:
In file included from /opt/local/include/opencv2/core/core.hpp:56:
In file included from /usr/include/c++/4.2.1/algorithm:64:
In file included from /usr/include/c++/4.2.1/bits/stl_algobase.h:70:
In file included from /usr/include/c++/4.2.1/iosfwd:48:
In file included from /usr/include/c++/4.2.1/bits/postypes.h:45:
In file included from /usr/include/c++/4.2.1/cwchar:51:
/usr/include/c++/4.2.1/ctime:65:11: error: no member named 'clock_t' in the global namespace
using ::clock_t;
~~^
/usr/include/c++/4.2.1/ctime:67:11: error: no member named 'tm' in the global namespace
using ::tm;
~~^
/usr/include/c++/4.2.1/ctime:69:11: error: no member named 'clock' in the global namespace
using ::clock;
~~^
/usr/include/c++/4.2.1/ctime:70:11: error: no member named 'difftime' in the global namespace
using ::difftime;
~~^
/usr/include/c++/4.2.1/ctime:71:11: error: no member named 'mktime' in the global namespace
using ::mktime;
~~^
/usr/include/c++/4.2.1/ctime:72:11: error: no member named 'time' in the global namespace
using ::time;
~~^
/usr/include/c++/4.2.1/ctime:73:11: error: no member named 'asctime' in the global namespace
using ::asctime;
~~^
/usr/include/c++/4.2.1/ctime:74:11: error: no member named 'ctime' in the global namespace
using ::ctime;
~~^
/usr/include/c++/4.2.1/ctime:75:11: error: no member named 'gmtime' in the global namespace
using ::gmtime;
~~^
/usr/include/c++/4.2.1/ctime:76:11: error: no member named 'localtime' in the global namespace
using ::localtime;
~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
I Tried also to change compiler to LLVM GCC 4.2 compiler with no luck.
Someone can 'tell me the exact steps to build projects on xcode using opencv Mountain Lion and Xcode 4.5?
Without access to your code, I can't say whether this would be a complete fix but, in order to to resolve your "no member named..." compilation errors, you might try substituting "/opt/local/lib" for "/opt/local/lib/**" by double clicking on the "Header Search Paths" field and selecting the "non-recursive" option under XCode's "Build Settings" > "Search Paths" > "Header Search Paths".
You could also try recompiling after navigating to "Build Settings" > "Apple LLVM compiler 4.2 - Language" > "C++ Standard Library", and selecting "libstdc++ (GNU C++ standard library)" rather than XCode 4.5's default "libc++ (LLVM C++ standard library with C++11 support)".
I would use a different installing command:
sudo port install tbb
sudo port install opencv +debug +eigen +python27 +qt4 +tbb
eigen and qt4 is optional, tbb is rather essential, since opencv uses tbb massively for multithreading when present. In other words, opencv is much slower without tbb.
I would not manually specify the compiler. As I remember that did not work for me.
make sure its compiled as c++, rename your m files to mm
Related
Platform: Macos Catalina 10.15.2
Xcode version: Xcode 11
I have tried many times to make-all gcc to build my source code. However, I have encountered a problem:
In file included from ../.././gcc/c/c-objc-common.c:33:
In file included from /Applications/Xcode11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/new:85:
/Applications/Xcode11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/exception:181:5: error:
no member named 'fancy_abort' in namespace 'std::__1'; did you mean simply 'fancy_abort'?
_VSTD::abort();
^~~~~~~ /Applications/Xcode11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:873:15: note:
expanded from macro '_VSTD' # _VSTD std::_LIBCPP_ABI_NAMESPACE
^ ../.././gcc/system.h:685:13: note: 'fancy_abort' declared here extern void fancy_abort (const char *, int, const char
*) ATTRIBUTE_NORETURN;
^
1 error generated.
make[1]: *** [c/c-objc-common.o] Error 1
make: *** [all-gcc] Error 2
I have tried to install another version of Xcode. I have installed Xcode6 but it still did not work, and I found a solution of this issue. But when I download Xcode8.3.3, it is not compatible with Catalina 10.15.2.
I ran in to this issue while using crosstools-ng on mac (mojave 10.14) to compile cross-platform toolchain with gcc 4.9.
Solution: Edit .build/src/gcc-4.9.4/gcc/system.h to add #include <map> in #ifdef __cplusplus block where other include statements are.
The problem is that is included (via ) after abort has been
defined as a macro to fancy_abort. And thus when the C++ standard headers try
to call std::abort, they end up calling std::fancy_abort, which of course
doesn't exist.
Source: https://gcc.gnu.org/legacy-ml/gcc-bugs/2017-09/msg00154.html
Command Line tools are giving a multitude of errors when trying to install MuJoCo. I suspect with high confidence that this is an issue from the command line tools on my macOS Catalina since I have installed mujoco previously on Mojave and multiple ubuntu machines. The following installations had worked on Mojave.
First I perform:
xcode-select --install
Further information:
(base) ryanr#RRMBP ~ % /usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I install using pip3 install 'mujoco-py<2.1,>=2.0'
I am greeted with errors as the following:
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:34:
> error: expected declaration specifiers before
> '__OSX_AVAILABLE_STARTING' int getiopolicy_np(int, int)
> __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
> ^~~~~~~~~~~~~~~~~~~~~~~~
and
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:144:1: error: expected declaration specifiers before 'div_t'
div_t div(int, int) __pure2;
^~~~~
and
In file included from /Users/ryanr/.mujoco/mujoco200/include/mujoco.h:34:0,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-4_wykvnc/mujoco-py/mujoco_py/gl/glshim.h:4,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-4_wykvnc/mujoco-py/mujoco_py/gl/dummyshim.c:1:
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:59:19: error: storage class specified for parameter 'float_t'
typedef float float_t;
^~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:60:20: error: storage class specified for parameter 'double_t'
typedef double double_t;
^~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:126:12: error: storage class specified for parameter '__math_errhandling'
extern int __math_errhandling(void);
^~~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:146:12: error: storage class specified for parameter '__fpclassifyf'
extern int __fpclassifyf(float);
^~~~~~~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:147:12: error: storage class specified for parameter '__fpclassifyd'
extern int __fpclassifyd(double);
^~~~~~~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:148:12: error: storage class specified for parameter '__fpclassifyl'
extern int __fpclassifyl(long double);
^~~~~~~~~~~~~
and
^
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/wait.h:110:0,
from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:66,
from /Users/ryanr/.mujoco/mujoco200/include/mujoco.h:33,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/glshim.h:4,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/dummyshim.c:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:9: error: old-style parameter declarations in prototyped function definition
int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
^~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:1: error: parameter name omitted
int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:1: error: parameter name omitted
/private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/dummyshim.c:37:1: error: expected '{' at end of input
}
^
error: command '/usr/local/bin/gcc-6' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mujoco-py
Any suggestions as to why my command-line tools are failing on macOS Catalina? What steps should one take to ensure that the command-line tools and gcc on Catalina are working as expected?
Pass the previous version’s OS X sdk as sysroot, instead of the unversioned sdk.
Command-line tools are failing on macOS Catalina due to incorrect SDK directory.
What steps should one take to ensure that the command-line tools and gcc on Catalina are working as expected? Reference the versioned SDK:
./configure --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
and/or
./configure --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
Installed g++ 4.9.0 (experimental) version under Ubuntu (I am using certain features provided by this version)
When building my code, I use cmake from a script, and it builds correctly. gcc below contains the path where g++ is installed (/mnt...)
$_cmake_ $_dir_ -DCMAKE_CXX_COMPILER=${_gpp_} -DCMAKE_C_COMPILER=${_gcc_} -DCMAKE_BUILD_TYPE=${_build_} -DCMAKE_INSTALL_PREFIX=${_install_} -DBUILD_TESTING:BOOL=1
Now, when I make the CppuTest to build the Unit Tests for my code, I get the following error.
make all
compiling UncrosserTest.cpp
In file included from /home/miguel/Desktop/Ugur/scmProject/scm/dist/dev/mfx_prod/scm/20160207/include/scm/services/primitives.hpp:4:0,
from /home/miguel/Desktop/Ugur/scmProject/log/lidya/src/cpp/scm/services/examples/dummy_strategy/Inside.hpp:6,
from AllTests/Uncrosser/UncrosserTest.cpp:7:
/usr/include/c++/4.9/experimental/optional: In member function ‘void std::experimental::_Optional_base<_Tp, _ShouldProvideDestructor>::_M_construct(_Args&& ...)’:
/usr/include/c++/4.9/experimental/optional:294:18: error: expected type-specifier
::new (std::__addressof(this->_M_payload))
^
/usr/include/c++/4.9/experimental/optional:294:18: error: expected ‘)’
/usr/include/c++/4.9/experimental/optional: In member function ‘void std::experimental::_Optional_base<_Tp, false>::_M_construct(_Args&& ...)’:
/usr/include/c++/4.9/experimental/optional:424:18: error: expected type-specifier
::new (std::__addressof(this->_M_payload))
^
/usr/include/c++/4.9/experimental/optional:424:18: error: expected ‘)’
make: *** [objs/AllTests/Uncrosser/UncrosserTest.o] Error 1
In the CppuTest makefile have included CPPUTEST_CPPFLAGS += -std=c++1y. I guess that am missing some flags in this makefile because as I said the C++ experimental library is building correctly in my "regular" code. What am I missing ?
Possible it's an include problem, see CppUTest Manual - section Conflicts with operator new macros (STL!) and Conflicts with my own overload!
TL;DR
In UncrosserTest add includes for CppUTest after your's.
Instead of
#include <CppUTest/TestHarnes.h>
#include "whatever.h"
do
#include "whatever.h"
#include <CppUTest/TestHarnes.h>
I'm trying to get OpenCV built on OSX (Yosemite), following this guide: http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/
Got the static libs built fine but when building the shared libs I get errors, including the following:
/Users/chrismash/Development/OSX/WireframeUpscaler/WireframeUpscaler/ThirdParty/opencv-3.0.0/modules/core/src/ocl.cpp:2700:49:
error:
use of undeclared identifier 'clEnqueueSVMUnmap'; did you mean
'svm::SVMFunctions::fn_clEnqueueSVMUnmap'? ...= clEnqueueSVMUnmap;
^~~~~~~~~~~~~~~~~
svm::SVMFunctions::fn_clEnqueueSVMUnmap
/Users/chrismash/Development/OSX/WireframeUpscaler/WireframeUpscaler/ThirdParty/opencv-3.0.0/modules/core/src/ocl.cpp:2700:49:
error:
invalid use of non-static data member 'fn_clEnqueueSVMUnmap'
svmFunctions.fn_clEnqueueSVMUnmap = clEnqueueSVMUnmap;
Any ideas where I might be going wrong...?
As #jprice pointed out it seems I somehow got the WITH_OPENCL_SVM option enabled in CMake. Because OS X doesn't support OpenCL 2.0 yet it should be unticked.
After upgrading to OS X Mavericks, running make in my Mesos build directory results in errors:
google/protobuf/message.cc:130:60: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >'
return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here
class _LIBCPP_TYPE_VIS basic_istream;
^
google/protobuf/message.cc:135:67: error: implicit instantiation of undefined template 'std::__1::basic_istream<char, std::__1::char_traits<char> >'
return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:108:28: note: template is declared here
class _LIBCPP_TYPE_VIS basic_istream;
^
google/protobuf/message.cc:175:16: error: implicit instantiation of undefined template 'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
return output->good();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/iosfwd:110:28: note: template is declared here
class _LIBCPP_TYPE_VIS basic_ostream;
I started with a clean build directory, re-ran ./bootstrap, and ran cd build && ../configure.
For people who find this page while Googling error messages thrown up by some other software that depends on old versions of Google's protobuf libraries, here's another solution:
Modify the file src/google/protobuf/message.cc and add the line #include <iostream> after the opening comment block, right before all the rest of the #include lines. That one-line change was enough to enable me to compile protoc from protobuf-2.4.1 with the command-line tools from XCode 7.3 on an El Capitan Mac.
OS X Mavericks replaced the gcc command with clang:
$ gcc
clang: error: no input files
However, Mesos currently expects to be compiled with the GNU Compiler Collection. You need to install GCC 4.7 with Homebrew and configure your build directory to use it. To be sure, start with an empty build directory:
# Install GCC 4.7
brew tap homebrew/versions
brew install gcc47
# Configure Mesos build to use GCC
cd /path/to/mesos
rm -rf build
mkdir build
cd build
CC=gcc-4.7 CXX=g++-4.7 ../configure
Then you can run make like before.