dyld:无法加载“my_program”(加载命令 0x80000034 未知)

问题描述 投票:0回答:1

我有一个 C++ 程序,我使用 Cmake 在 Mac OS 13.4.1 上编译

我的一位用户遇到以下错误:

dyld: cannot load 'my_program' (load command 0x80000034 is unknown)

我不知道为什么他会出现此错误消息,他使用的是 Mac OS 10.14.6,而我们都使用 Intel Mac

以下是有关二进制文件的一些可能有用的信息:

otool -L my_program
my_program:
        /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1500.65.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
otool -l my_program
my_program:
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __PAGEZERO
   vmaddr 0x0000000000000000
   vmsize 0x0000000100000000
  fileoff 0
 filesize 0
  maxprot 0x00000000
 initprot 0x00000000
   nsects 0
    flags 0x0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 712
  segname __TEXT
   vmaddr 0x0000000100000000
   vmsize 0x0000000001374000
  fileoff 0
 filesize 20398080
  maxprot 0x00000005
 initprot 0x00000005
   nsects 8
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x0000000100001d00
      size 0x00000000010ae186
    offset 7424
     align 2^6 (64)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __stubs
   segname __TEXT
      addr 0x00000001010afe86
      size 0x000000000000063c
    offset 17497734
     align 2^1 (2)
    reloff 0
    nreloc 0
     flags 0x80000408
 reserved1 0 (index into indirect symbol table)
 reserved2 6 (size of stubs)
Section
  sectname __init_offsets
   segname __TEXT
      addr 0x00000001010b04c4
      size 0x000000000000003c
    offset 17499332
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000016
 reserved1 0
 reserved2 0
Section
  sectname __gcc_except_tab
   segname __TEXT
      addr 0x00000001010b0500
      size 0x000000000001a69c
    offset 17499392
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __const
   segname __TEXT
      addr 0x00000001010cabc0
      size 0x000000000012f0de
    offset 17607616
     align 2^6 (64)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x00000001011f9ca0
      size 0x00000000000ac6f8
    offset 18848928
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x00000001012a6398
      size 0x0000000000014ef8
    offset 19555224
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __eh_frame
   segname __TEXT
      addr 0x00000001012bb290
      size 0x00000000000b8d38
    offset 19640976
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 232
  segname __DATA_CONST
   vmaddr 0x0000000101374000
   vmsize 0x000000000001c000
  fileoff 20398080
 filesize 114688
  maxprot 0x00000003
 initprot 0x00000003
   nsects 2
    flags 0x10
Section
  sectname __got
   segname __DATA_CONST
      addr 0x0000000101374000
      size 0x0000000000000d78
    offset 20398080
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 266 (index into indirect symbol table)
 reserved2 0
Section
  sectname __const
   segname __DATA_CONST
      addr 0x0000000101374d80
      size 0x0000000000017b58
    offset 20401536
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 3
      cmd LC_SEGMENT_64
  cmdsize 312
  segname __DATA
   vmaddr 0x0000000101390000
   vmsize 0x0000000000034000
  fileoff 20512768
 filesize 81920
  maxprot 0x00000003
 initprot 0x00000003
   nsects 3
    flags 0x0
Section
  sectname __data
   segname __DATA
      addr 0x0000000101390000
      size 0x0000000000011050
    offset 20512768
     align 2^6 (64)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Section
  sectname __bss
   segname __DATA
      addr 0x00000001013a1080
      size 0x000000000001ec48
    offset 0
     align 2^6 (64)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Section
  sectname __common
   segname __DATA
      addr 0x00000001013bfcd0
      size 0x00000000000007f0
    offset 0
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x00000001
 reserved1 0
 reserved2 0
Load command 4
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x00000001013c4000
   vmsize 0x00000000001b4000
  fileoff 20594688
 filesize 1772472
  maxprot 0x00000001
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 5
      cmd LC_DYLD_CHAINED_FIXUPS
  cmdsize 16
  dataoff 20594688
 datasize 25456
Load command 6
      cmd LC_DYLD_EXPORTS_TRIE
  cmdsize 16
  dataoff 20620144
 datasize 177624
Load command 7
     cmd LC_SYMTAB
 cmdsize 24
  symoff 20829768
   nsyms 29929
  stroff 21311424
 strsize 1055736
Load command 8
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 21530
     iextdefsym 21530
     nextdefsym 7957
      iundefsym 29487
      nundefsym 442
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 21308632
  nindirectsyms 697
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 9
          cmd LC_LOAD_DYLINKER
      cmdsize 32
         name /usr/lib/dyld (offset 12)
Load command 10
     cmd LC_UUID
 cmdsize 24
    uuid 482C4C59-09D1-358F-85F5-B6D96F0D359F
Load command 11
      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 13.0
      sdk 13.3
   ntools 1
     tool 3
  version 857.1
Load command 12
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 13
       cmd LC_MAIN
   cmdsize 24
  entryoff 7424
 stacksize 0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (offset 24)
   time stamp 2 Wed Dec 31 20:00:02 1969
      current version 1.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 20:00:02 1969
      current version 1500.65.0
compatibility version 1.0.0
Load command 16
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Wed Dec 31 20:00:02 1969
      current version 1319.100.3
compatibility version 1.0.0
Load command 17
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 20797768
 datasize 30104
Load command 18
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 20827872
 datasize 1896
macos linker macos-mojave mac-app-store dyld
1个回答
0
投票

我不知道为什么他会出现此错误消息,他使用的是 Mac OS 10.14.6,而我们都使用 Intel Mac

这应该意味着

LC_BUILD_VERSION
加载命令(0x80000034)在用户的 Mac OS 版本(10.14.6)上无法识别,因为它是在更高版本的 macOS 中引入的(之前:
LC_VERSION_MIN_MACOSX
)。

load
命令用于指定二进制文件可以运行的最低操作系统版本,以及用于构建它的 SDK 版本。

在您的

CMakeLists.txt
中,指定您的开发环境和用户环境都支持的较低目标 macOS 版本。

set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version" FORCE)

正如此处指出,可能需要

FORCE
参数。

然后重新编译你的程序。

mkdir build
cd build
cmake ..
make

并将新编译的二进制文件分发给用户,供他们检查问题是否仍然存在。

© www.soinside.com 2019 - 2024. All rights reserved.