所以我从苹果开源网站下载了otool: https://opensource.apple.com/tarballs/cctools/cctools-895.tar.gz
然后我使用CLion(IDE)打开otool并尝试构建它。 CLion似乎为我生成CMakeLists.txt
,当我点击构建时,它会说:
[ 89%] Building C object CMakeFiles/otool.dir/print_objc2_64bit.c.o
[ 94%] Building C object CMakeFiles/otool.dir/sparc_disasm.c.o
[100%] Linking C executable otool
Undefined symbols for architecture x86_64:
"_SWAP_DOUBLE", referenced from:
_print_ef in m68k_disasm.c.o
_print_literal8_section in ofile_print.c.o
_print_literal_pointer_section in ofile_print.c.o
"_SWAP_FLOAT", referenced from:
_print_insn_neon in arm_disasm.c.o
_print_ef in m68k_disasm.c.o
_print_literal4_section in ofile_print.c.o
"_SWAP_LONG_LONG", referenced from:
_guess_pointer_pointer in arm64_disasm.c.o
_guess_pointer_pointer in i386_disasm.c.o
_print_library_toc in ofile_print.c.o
_print_literal_pointer_section in ofile_print.c.o
_print_init_term_pointer_section in ofile_print.c.o
_walk_pointer_list in print_objc2_64bit.c.o
_swap_cfstring_t in print_objc2_64bit.c.o
...
"_allocate", referenced from:
_method_reference in arm64_disasm.c.o
_get_dyld_bind_info in dyld_bind_info.c.o
_method_reference in i386_disasm.c.o
_main in main.c.o
_processor in main.c.o
_setup_dyld_bind_info in main.c.o
_print_text in main.c.o
...
"_apple_version", referenced from:
_main in main.c.o
_version in main.c.o
"_arch_usage", referenced from:
_main in main.c.o
"_assemble_12", referenced from:
_hppa_disassemble in hppa_disasm.c.o
"_assemble_17", referenced from:
_hppa_disassemble in hppa_disasm.c.o
"_assemble_21", referenced from:
_hppa_disassemble in hppa_disasm.c.o
"_assemble_3", referenced from:
_hppa_disassemble in hppa_disasm.c.o
"_error", referenced from:
_main in main.c.o
_print_bitcode_section in print_bitcode.c.o
_print_xar_files_summary in print_bitcode.c.o
"_error_with_arch", referenced from:
_print_library_toc in ofile_print.c.o
_print_sysv_library_toc in ofile_print.c.o
"_errors", referenced from:
_main in main.c.o
"_get_arch_from_flag", referenced from:
_main in main.c.o
"_get_host_byte_sex", referenced from:
_arm64_disassemble in arm64_disasm.c.o
_guess_pointer_pointer in arm64_disasm.c.o
_guess_cstring_pointer in arm64_disasm.c.o
_guess_literal_pointer in arm_disasm.c.o
_guess_cstring_pointer in arm_disasm.c.o
_print_insn_neon in arm_disasm.c.o
_print_coff_reloc_section in coff_print.c.o
...
"_get_stack_addr_from_flag", referenced from:
_print_argstrings in main.c.o
"_get_toc_byte_sex", referenced from:
_processor in main.c.o
"_guess_short_name", referenced from:
_setup_dyld_bind_info in main.c.o
_print_hints in ofile_print.c.o
"_llvm_create_disasm", referenced from:
_create_arm64_llvm_disassembler in arm64_disasm.c.o
_create_arm_llvm_disassembler in arm_disasm.c.o
_create_thumb_llvm_disassembler in arm_disasm.c.o
_create_i386_llvm_disassembler in i386_disasm.c.o
_create_x86_64_llvm_disassembler in i386_disasm.c.o
"_llvm_disasm_dispose", referenced from:
_delete_arm64_llvm_disassembler in arm64_disasm.c.o
_delete_arm_llvm_disassembler in arm_disasm.c.o
_delete_thumb_llvm_disassembler in arm_disasm.c.o
_delete_i386_llvm_disassembler in i386_disasm.c.o
_delete_x86_64_llvm_disassembler in i386_disasm.c.o
"_llvm_disasm_instruction", referenced from:
_arm64_disassemble in arm64_disasm.c.o
_print_insn in arm_disasm.c.o
_i386_disassemble in i386_disasm.c.o
"_llvm_disasm_set_options", referenced from:
_print_text in main.c.o
"_llvm_disasm_version_string", referenced from:
_main in main.c.o
"_low_sign_ext", referenced from:
_hppa_disassemble in hppa_disasm.c.o
"_makestr", referenced from:
_print_bitcode_section in print_bitcode.c.o
"_ofile_process", referenced from:
_main in main.c.o
"_reallocate", referenced from:
_main in main.c.o
_print_text in main.c.o
_print_reloc in ofile_print.c.o
_print_indirect_symbols in ofile_print.c.o
_print_hints in ofile_print.c.o
_print_literal_pointer_section in ofile_print.c.o
_get_objc_sections in print_objc.c.o
...
"_reloc_has_pair", referenced from:
_get_symbol_32 in print_objc2_32bit.c.o
_get_symbol_64 in print_objc2_64bit.c.o
"_sign_ext", referenced from:
_hppa_disassemble in hppa_disasm.c.o
_print_immediate in hppa_disasm.c.o
"_size_ar_name", referenced from:
_print_ar_hdr in ofile_print.c.o
"_swap_arm_thread_state64_t", referenced from:
_print_thread_states in ofile_print.c.o
"_swap_arm_thread_state_t", referenced from:
_print_thread_states in ofile_print.c.o
"_swap_base_relocation_block_header", referenced from:
_print_coff_reloc_section in coff_print.c.o
"_swap_base_relocation_entry", referenced from:
_print_coff_reloc_section in coff_print.c.o
"_swap_data_in_code_entry", referenced from:
_processor in main.c.o
"_swap_ppc_thread_state64_t", referenced from:
_print_thread_states in ofile_print.c.o
"_swap_twolevel_hint", referenced from:
_processor in main.c.o
"_swap_xar_header", referenced from:
_print_bitcode_section in print_bitcode.c.o
"_system_error", referenced from:
_print_bitcode_section in print_bitcode.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [otool] Error 1
make[2]: *** [CMakeFiles/otool.dir/all] Error 2
make[1]: *** [CMakeFiles/otool.dir/rule] Error 2
make: *** [otool] Error 2
这是CMakeLists.txt:
cmake_minimum_required(VERSION 3.8)
project(otool)
include_directories( ../include )
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES
arm64_disasm.c
arm64_disasm.h
arm_disasm.c
arm_disasm.h
coff_print.c
cxa_demangle.h
dyld_bind_info.c
dyld_bind_info.h
hppa_disasm.c
hppa_disasm.h
i386_disasm.c
i386_disasm.h
i860_disasm.c
i860_disasm.h
m68k_disasm.c
m68k_disasm.h
m88k_disasm.c
m88k_disasm.h
main.c
notify.c
notify.h
ofile_print.c
ofile_print.h
otool.h
ppc_disasm.c
ppc_disasm.h
print_bitcode.c
print_objc.c
print_objc2_32bit.c
print_objc2_64bit.c
sparc_disasm.c
sparc_disasm.h)
add_executable(otool ${SOURCE_FILES})
我不知道CMake,我该如何解决?具体来说,我如何知道导致问题的lib,以及如何将它们添加到CMakeLists中?谢谢!