Skip to content

[构建错误] Linux 下因可执行文件名与目录重名导致链接失败 #51

@bobisuperplus-sys

Description

@bobisuperplus-sys

问题描述 在 Linux 环境下构建项目时编译失败。原因是生成的可执行文件名称 (SmartMealPro) 与现有的源码目录 src/SmartMealPro 重名,导致冲突。

错误日志

:-1: cannot open output file src/SmartMealPro: Is a directory

截图

Image

解决方案 可以通过在 CMakeLists.txt 中分离运行时输出目录来修复此问题。

添加以下配置即可解决:

# 针对 Linux 构建的修复:将二进制文件输出到单独的 'bin' 目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions