【问题标题】:How does one compile a 64 bit macOS application with NASM application using CMake?如何使用 CMake 编译带有 NASM 应用程序的 64 位 macOS 应用程序?
【发布时间】:2018-09-28 23:05:38
【问题描述】:

查看source 设置CMAKE_ASM_NASM_OBJECT_FORMAT 应该就足够了,但似乎并非如此。

我希望以下内容能够使用 macho64 文件格式为 macOS 应用程序创建有效的构建配置。

project(hello_world ASM_NASM)
set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
add_executable(hello_world source/main.asm)

但是,当使用 VERBOSE=1 运行 make 时

/usr/local/bin/nasm   -f macho -o CMakeFiles/main.dir/source/main.asm.o /hello-world/source/main.asm
/hello-world/source/main.asm:6: error: instruction not supported in 32-bit mode
/hello-world/source/main.asm:7: error: instruction not supported in 32-bit mode
/hello-world/source/main.asm:8: error: instruction not supported in 32-bit mode
/hello-world/source/main.asm:9: error: instruction not supported in 32-bit mode
/hello-world/source/main.asm:12: error: instruction not supported in 32-bit mode
/hello-world/source/main.asm:13: error: instruction not supported in 32-bit mode
make[2]: *** [CMakeFiles/main.dir/source/main.asm.o] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2

我们可以清楚地看到 32 位版本的 mach-o 被传递给格式标志,而不是预期的 64 位版本:macho64

版本

  • CMake 3.12.2
  • NASM 2.13.03
  • macOS 10.14

【问题讨论】:

  • project() 调用中检查编译器。可能,您需要在调用之前移动设置CMAKE_ASM_NASM_OBJECT_FORMAT 变量
  • 原来如此,呵呵!如果您创建答案,我会继续接受。谢谢@Tsyvarev

标签: macos assembly cmake nasm mach-o


【解决方案1】:

project() 调用中检查编译器。

您需要在调用之前移动设置CMAKE_ASM_NASM_OBJECT_FORMAT 变量

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-19
    • 1970-01-01
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2010-12-24
    相关资源
    最近更新 更多