can't get opencv-based application to run on Macbook older than mine

0

I have already compiled opencv on the Mac and created a MacOS application based on it. It currently works on a variety of Macs for the past couple months. However, my Macbook is a Late 2013. Right now, no users with Early 2013 Macbooks or older can run it.

I have tried several different ways to compile OpenCV on the Mac in order to get it to work on a computer older than mine but have not been successful. My application is and has been running for months on 50+ Macs but they are all Late 2013 Macbooks or newer. I have confirmed that it runs on older operating systems. For example, I run High Sierra 10.13 and I've seen my application run on a system with 10.10.5 and 10.12 systems. Even Early 2013 Macbooks don't run my application. My goal is to get the application to run on older Macs than mine which is a Late 2013 Macbook Pro.

I use Xcode 9.2. I use brew to compile OpenCV. In this example, I was using opencv 3.4.0. I also tried 3.4.1 and it didn't work either. I'm sure I'm missing some simple setting.

I currently compile with this setting but it is not enough:

-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9

I tried compiling with this flag but it didn't help. i thought this flag would tell the compiler to target an older architecture but it didn't work:

-DCMAKE_CXX_COMPILER_TARGET=x86_64-apple-darwin15.5.0

the crash log from the Macbook from 2010 looks like this:

Process:               Brightday [17622]
Path:                  /Users/USER/Downloads/Brightday.app/Contents/MacOS/Brightday
Identifier:            com.brightday.Brightday
Version:               47 (47)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Brightday [17622]
User ID:               502

Date/Time:             2018-01-22 17:46:07.436 -0800
OS Version:            Mac OS X 10.11.5 (15F34)
Report Version:        11
Anonymous UUID:        333100CF-2D55-443A-78BE-49F842AC3DD4

Sleep/Wake UUID:       B8FBAF9B-42C4-450F-905D-74EAE4B19AD9

Time Awake Since Boot: 600000 seconds
Time Since Wake:       5100 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
/Users/USER/Downloads/Brightday.app/Contents/MacOS/../Frameworks/../Frameworks/opencv/libopencv_core.3.4.0.dylib

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libopencv_core.3.4.0.dylib      0x000000010f8e7556 _GLOBAL__sub_I_persistence.cpp + 44
1   dyld                            0x00007fff6606510b ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 265
2   dyld                            0x00007fff66065284 ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
3   dyld                            0x00007fff660618bd ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 305
4   dyld                            0x00007fff66061852 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 198
5   dyld                            0x00007fff66061743 ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 127
6   dyld                            0x00007fff660619b3 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 75
7   dyld                            0x00007fff660540f1 dyld::initializeMainExecutable() + 208
8   dyld                            0x00007fff66057d98 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 3596
9   dyld                            0x00007fff66053276 dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 512
10  dyld                            0x00007fff66053036 _dyld_start + 54

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x000000011003b6d1  rbx: 0x00007fff50563650  rcx: 0x00007fff50566d40  rdx: 0x00007fff50566ce0
  rdi: 0x0000000000000001  rsi: 0x00007fff50566cd0  rbp: 0x00007fff505636c0  rsp: 0x00007fff50563650
   r8: 0x00007fff6608b630   r9: 0x000000000000002c  r10: 0x00007fff50566d38  r11: 0x0000000000000000
  r12: 0x00000001102758e8  r13: 0x00007fff6608b568  r14: 0x00007fff66093b78  r15: 0x0000000000000001
  rip: 0x000000010f8e7556  rfl: 0x0000000000010246  cr2: 0x000000010f8e752a

Logical CPU:     2
Error Code:      0x00000000
Trap Number:     6


Binary Images:
       0x10f699000 -        0x10f71bfff +com.brightday.Brightday (47 - 47) <C4224EF0-C56D-3124-80DF-2394BAEF1392> /Users/USER/Downloads/Brightday.app/Contents/MacOS/Brightday
       0x10f75d000 -        0x110274fe7 +libopencv_core.3.4.0.dylib (0) <59A4B9B9-1E75-3314-AF6C-E6C6D6AB98A4> /Users/USER/Downloads/Brightday.app/Contents/Frameworks/opencv/libopencv_core.3.4.0.dylib
       0x1103ec000 -        0x11047bfef +libopencv_features2d.3.4.0.dylib (0) <4BC1D301-389F-34CE-BE2E-60F2EA549F2C> /Users/USER/Downloads/Brightday.app/Contents/Frameworks/opencv/libopencv_features2d.3.4.0.dylib
       0x1104ae000 -        0x1104e8ffb +libopencv_flann.3.4.0.dylib (0) <1052FC33-9DEA-3B9F-9C8E-6036FCE6DB9E> /Users/USER/Downloads/Brightday.app/Contents/Frameworks/opencv/libopencv_flann.3.4.0.dylib

from this command:

otool -l libopencv_core.3.4.1.dylib 

I get this output

libopencv_core.3.4.1.dylib:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x00           6    19       2184 0x00118085
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 632
  segname __TEXT
   vmaddr 0x0000000000000000
   vmsize 0x000000000024a000
  fileoff 0
 filesize 2400256
  maxprot 0x00000007
 initprot 0x00000005
   nsects 7
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x0000000000002610
      size 0x00000000001bf9c7
    offset 9744
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x00000000001c1fd8
      size 0x000000000000052e
    offset 1843160
     align 2^1 (2)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 6 (size of stubs)
Section
  sectname __stub_helper
   segname __TEXT
      addr 0x00000000001c2508
      size 0x000000000000088a
    offset 1844488
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __gcc_except_tab
   segname __TEXT
      addr 0x00000000001c2d94
      size 0x000000000003bfa0
    offset 1846676
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x00000000001fed40
      size 0x000000000003b1f2
    offset 2092352
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __TEXT
      addr 0x0000000000239f40
      size 0x000000000000a21c
    offset 2334528
     align 2^5 (32)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x000000000024415c
      size 0x0000000000005e90
    offset 2376028
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 712
  segname __DATA
   vmaddr 0x000000000024a000
   vmsize 0x0000000000010000
  fileoff 2400256
 filesize 45056
  maxprot 0x00000007
 initprot 0x00000003
   nsects 8
    flags 0x0
Section
  sectname __got
   segname __DATA
      addr 0x000000000024a000
      size 0x0000000000000188
    offset 2400256
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 221 (index into indirect symbol table)
 reserved2 0
Section
  sectname __nl_symbol_ptr
   segname __DATA
      addr 0x000000000024a188
      size 0x0000000000000010
    offset 2400648
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 270 (index into indirect symbol table)
 reserved2 0
Section
  sectname __la_symbol_ptr
   segname __DATA
      addr 0x000000000024a198
      size 0x00000000000006e8
    offset 2400664
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000007
 reserved1 272 (index into indirect symbol table)
 reserved2 0
Section
  sectname __mod_init_func
   segname __DATA
      addr 0x000000000024a880
      size 0x0000000000000040
    offset 2402432
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000009
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __DATA
      addr 0x000000000024a8c0
      size 0x0000000000005090
    offset 2402496
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __data
   segname __DATA
      addr 0x000000000024f950
      size 0x0000000000004aa0
    offset 2423120
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __bss
   segname __DATA
      addr 0x0000000000254400
      size 0x0000000000004fb6
    offset 0
     align 2^5 (32)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Section
  sectname __common
   segname __DATA
      addr 0x00000000002593b8
      size 0x0000000000000059
    offset 0
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x000000000025a000
   vmsize 0x0000000000085000
  fileoff 2445312
 filesize 543516
  maxprot 0x00000007
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 3
          cmd LC_ID_DYLIB
      cmdsize 80
         name /usr/local/opt/opencv/lib/libopencv_core.3.4.dylib (offset 24)
   time stamp 1 Wed Dec 31 16:00:01 1969
      current version 3.4.1
compatibility version 3.4.0
Load command 4
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 2445312
    rebase_size 1616
       bind_off 2446928
      bind_size 5176
  weak_bind_off 2452104
 weak_bind_size 1560
  lazy_bind_off 2453664
 lazy_bind_size 7616
     export_off 2461280
    export_size 55288
Load command 5
     cmd LC_SYMTAB
 cmdsize 24
  symoff 2523664
   nsyms 8017
  stroff 2653908
 strsize 334920
Load command 6
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 5832
     iextdefsym 5832
     nextdefsym 1824
      iundefsym 7656
      nundefsym 361
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 2651936
  nindirectsyms 493
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 7
     cmd LC_UUID
 cmdsize 24
    uuid 148A22D3-49C6-3F35-BA2C-E3C83AEC474A
Load command 8
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.9
      sdk 10.13
Load command 9
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 10
          cmd LC_LOAD_DYLIB
      cmdsize 64
         name /usr/local/opt/tbb/lib/libtbb.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 0.0.0
compatibility version 0.0.0
Load command 11
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libz.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1.2.11
compatibility version 1.0.0
Load command 12
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1.0.0
compatibility version 1.0.0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 4.0.0
compatibility version 1.0.0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 1252.0.0
compatibility version 1.0.0
Load command 15
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name /usr/lib/libc++.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 400.9.0
compatibility version 1.0.0
Load command 16
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 2516568
 datasize 6528
Load command 17
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 2523096
 datasize 568
Load command 18
          cmd LC_RPATH
      cmdsize 48
         path /usr/local/Cellar/opencv/3.4.1/lib (offset 12)

Here's the output from

brew edit opencv

class Opencv < Formula
desc "Open source computer vision library"
 homepage "https://opencv.org/"
url "https://github.com/opencv/opencv/archive/3.4.1.tar.gz"
sha256 "ac627047c2afbbcb0ddd9583342f03c8e700032c9a77721a52c39c9d96790dbb"

 bottle do
  sha256 "e076e80bc5fe389bab1a8c1ba767fe737d4143b832830829681b5114203f0a78" => :high_sierra
  sha256 "afac0a89c93c20e90b28292a72a91d088ef03b528f82ed01679f92df6696e56c" => :sierra
   sha256 "639b043ae297109902edea2a6fcfff7da74caed73f3e5a5cc0fddf9743dc8fbe" => :el_capitan
 end

depends_on "cmake" => :build
 depends_on "pkg-config" => :build
 depends_on "eigen"

needs :cxx11

resource "contrib" do
  url "https://github.com/opencv/opencv_contrib/archive/3.4.1.tar.gz"
  sha256 "298c69ee006d7675e1ff9d371ba8b0d9e7e88374bb7ba0f9d0789851d352ec6e"
end

def install
  ENV.cxx11

  resource("contrib").stage buildpath/"opencv_contrib"

  args = std_cmake_args + %W[
  -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
  -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9
  -DBUILD_opencv_aruco=OFF
  -DBUILD_opencv_bgsegm=OFF
  -DBUILD_opencv_bioinspired=OFF
  -DBUILD_opencv_calib3d=OFF
  -DBUILD_opencv_ccalib=OFF
  -DBUILD_opencv_dpm=OFF
  -DBUILD_opencv_face=OFF
  -DBUILD_opencv_fuzzy=OFF
  -DBUILD_opencv_img_hash=OFF
  -DBUILD_opencv_line_descriptor=OFF
  -DBUILD_opencv_optflow=OFF
  -DBUILD_opencv_phase_unwrapping=OFF
  -DBUILD_opencv_reg=OFF
  -DBUILD_opencv_rgbd=OFF
  -DBUILD_opencv_saliency=OFF
  -DBUILD_opencv_shape=OFF
  -DBUILD_opencv_stereo=OFF
  -DBUILD_opencv_stitching=OFF
  -DBUILD_opencv_structured_light=OFF
  -DBUILD_opencv_superres=OFF
  -DBUILD_opencv_surface_matching=OFF
  -DBUILD_opencv_videostab=OFF
  -DBUILD_opencv_xfeatures2d=OFF
  -DBUILD_opencv_ximgproc=OFF
  -DBUILD_opencv_xobjdetect=OFF
  -DBUILD_opencv_xphoto=OFF
  -DCMAKE_BUILD_TYPE=RELEASE
  -DWITH_OPENMP=ON
  -DWITH_IPP=ON
  -DWITH_NVCUVID=ON
  -DBUILD_opencv_cudaarithm=ON
  -DBUILD_opencv_cudafilters=ON
  -DBUILD_opencv_cudaimgproc=ON
  -DBUILD_opencv_cudafeatures2d=ON
  -DWITH_CUDA=ON
  -DENABLE_FAST_MATH=1
  -DCUDA_FAST_MATH=1
  -DWITH_CUBLAS=1
  -DWITH_CUFFT=1
  -DWITH_CSTRIPES=ON
  -DBUILD_JASPER=OFF
  -DBUILD_JPEG=ON
  -DBUILD_OPENEXR=ON
  -DBUILD_PERF_TESTS=OFF
  -DBUILD_PNG=ON
  -DBUILD_TESTS=OFF
  -DBUILD_TIFF=ON
  -DBUILD_ZLIB=OFF
  -DBUILD_opencv_java=OFF
  -DOPENCV_ENABLE_NONFREE=OFF
  -DOPENCV_EXTRA_MODULES_PATH=#{buildpath}/opencv_contrib/modules
  -DWITH_1394=OFF
  -DWITH_EIGEN=ON
  -DWITH_FFMPEG=OFF
  -DWITH_GPHOTO2=OFF
  -DWITH_GSTREAMER=OFF
  -DWITH_JASPER=OFF
  -DWITH_OPENEXR=ON
  -DWITH_OPENGL=OFF
  -DWITH_QT=OFF
  -DWITH_TBB=ON
  -DWITH_VTK=OFF
  -DBUILD_opencv_python2=OFF
  -DBUILD_opencv_python3=OFF
  -DCPU_BASELINE=SSE2
  -DCPU_DISPATCH=SSE4_2,AVX2
]

if build.bottle?
  args += %w[-DCPU_BASELINE=SSE2 -DCPU_DISPATCH=SSE4_2,AVX]
end

mkdir "build" do
  system "cmake", "..", *args
  system "make"
  system "make", "install"
  end
end

test do
  (testpath/"test.cpp").write <<~EOS
    #include <opencv/cv.h>
    #include <iostream>
    int main() {
      std::cout << CV_VERSION << std::endl;
    return 0;
  }
EOS
system ENV.cxx, "test.cpp", "-I#{include}", "-L#{lib}", "-o", "test"
assert_equal `./test`.strip, version.to_s

["python", "python3"].each do |python|
  output = shell_output("#{python} -c 'import cv2; print(cv2.__version__)'")
  assert_equal version.to_s, output.chomp
  end
 end
end
c++
macos
opencv
asked on Stack Overflow Mar 14, 2018 by Jim M.

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0