I am trying to build a library on my mac (OSX Version 10.14.1, Xcode Version 10.1) and it fails giving following error:
Building target: application.a
ar -r "application.a" api.o
ar: creating archive application.a
/opt/local/bin/ranlib: object: application.a(api.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make[1]: *** [application.a] Error 1
make: *** [all] Error 2
by running 'otool -l lib/api.o' I get the following result:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
0xfeedfacf 16777223 3 0x00 1 5 616 0x00002000
Load command 0
cmd LC_SEGMENT_64
cmdsize 472
segname
vmaddr 0x0000000000000000
vmsize 0x0000000000004fb0
fileoff 648
filesize 20400
maxprot 0x00000007
initprot 0x00000007
nsects 5
flags 0x0
Section
sectname __text
segname __TEXT
addr 0x0000000000000000
size 0x00000000000040ae
offset 648
align 2^4 (16)
reloff 21048
nreloc 329
flags 0x80000400
reserved1 0
reserved2 0
Section
sectname __cstring
segname __TEXT
addr 0x00000000000040ae
size 0x00000000000000cb
offset 17206
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000002
reserved1 0
reserved2 0
Section
sectname __const
segname __TEXT
addr 0x0000000000004180
size 0x000000000000003f
offset 17416
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __compact_unwind
segname __LD
addr 0x00000000000041c0
size 0x00000000000005e0
offset 17480
align 2^3 (8)
reloff 23680
nreloc 47
flags 0x02000000
reserved1 0
reserved2 0
Section
sectname __eh_frame
segname __TEXT
addr 0x00000000000047a0
size 0x0000000000000810
offset 18984
align 2^3 (8)
reloff 0
nreloc 0
flags 0x6800000b
reserved1 0
reserved2 0
Load command 1
cmd ?(0x00000032)
cmdsize 24
Load command 2
cmd LC_DATA_IN_CODE
cmdsize 16
dataoff 24056
datasize 8
Load command 3
cmd LC_SYMTAB
cmdsize 24
symoff 24064
nsyms 93
stroff 25552
strsize 1668
Load command 4
cmd LC_DYSYMTAB
cmdsize 80
ilocalsym 0
nlocalsym 15
iextdefsym 15
nextdefsym 39
iundefsym 54
nundefsym 39
tocoff 0
ntoc 0
modtaboff 0
nmodtab 0
extrefsymoff 0
nextrefsyms 0
indirectsymoff 0
nindirectsyms 0
extreloff 0
nextrel 0
locreloff 0
nlocrel 0
I am guessing load command miss matches between my gcc and osx version, but I can't find 0x00000032 command on mach-o/loader.h. does anyone have a clue about this?
here is the 'otool --version':
llvm-otool(1): Apple Inc. version cctools-895
LLVM (http://llvm.org/):
LLVM version 4.0.1
Optimized build.
Default target: x86_64-apple-darwin18.2.0
Host CPU: haswell
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
armeb - ARM (big endian)
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
mips - Mips
mips64 - Mips64 [experimental]
mips64el - Mips64el [experimental]
mipsel - Mipsel
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
riscv32 - 32-bit RISC-V
riscv64 - 64-bit RISC-V
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
Do you have macports installed? I had the same issue and it seems that macports cctool
package install /opt/local/bin/otool
which is likely ahead in your path. I suspect that /usr/bin/otool
gives the right one ...
User contributions licensed under CC BY-SA 3.0