【问题标题】:Cmake with Qt: Clang: error: no such file or directory ' " ', /bin/sh: ": command not foundCmake with Qt: Clang: error: no such file or directory '"', /bin/sh:": command not found
【发布时间】:2017-06-21 16:50:36
【问题描述】:

使用 CMake 为我正在处理的 Qt 项目生成 makefile 后,当我使用 make 命令构建程序时,它找不到它需要的文件。以下是错误消息:

clang: error: no such file or directory: ' " '
clang: error: no input files
/bin/sh ": command not found
make[2]: *** [CMakeFiles/2d_cell_sim_2d_cell_sim.dir/main.cpp.o] Error 127
make[1]: *** [CMakeFiles/2d_cell_sim_2d_cell_sim.dir/all] Error 2
make: *** [all] Error 2

这里是 CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)

project(2d_cell_sim)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

set(CMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.9.0)

# Find the QtWidgets library
find_package(Qt5Widgets)

include_directories(${Qt5Widgets_INCLUDE_DIRS})

add_definitions(${Qt5Widgets_DEFINITIONS})

set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}”)

add_executable(${PROJECT_NAME}_2d_cell_sim
    main.cpp
    root.cpp
    cell.cpp
    view.cpp
    mainwindow.cpp
    scene.cpp
    robot.cpp
    startupdialog.cpp)

target_link_libraries(${PROJECT_NAME}_2d_cell_sim Qt5::Widgets)

我不确定为什么它似乎在寻找一个标题为“...

【问题讨论】:

  • 不要链接到错误消息(或与问题相关的任何其他内容)。将它们直接放入问题中,作为文本
  • 很抱歉。我编辑它来改变它。这是我第一次发帖,所以我不知道发帖的正确方法。
  • 没有伤害。感谢您的编辑。您可能想阅读:stackoverflow.com/tourstackoverflow.com/help/how-to-ask
  • 与 shell 脚本不同,在 CMake 中赋值不使用等号(参见赋值给CMAKE_PREFIX_PATH)。

标签: c++ qt makefile cmake


【解决方案1】:

在 CMake 中,只有 标准 双引号 (") 具有特殊含义。非标准字符 () 被视为普通字符。

换句话说,不要在 CMake 脚本中使用非标准的双引号

【讨论】:

  • 这解决了问题。太感谢了!我试图投票赞成你的答案,但由于我的声望分数低于 15,因此不会公开显示。
猜你喜欢
  • 2018-11-22
  • 1970-01-01
  • 2014-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-11
  • 2012-06-03
相关资源
最近更新 更多