CMake 找不到源文件,即使它位于正确的位置 [关闭]
Posted
技术标签:
【中文标题】CMake 找不到源文件,即使它位于正确的位置 [关闭]【英文标题】:CMake cannot find source file, even though it is in the correct location [closed] 【发布时间】:2019-04-05 16:39:21 【问题描述】:我正在为 easypaint 添加一些镜像效果。在构建项目时,我遇到了一个问题。当我在 CMake 中运行生成时(是的,我知道 QMake 会更好,但我们必须使用 CMake),它一直在 CMakeLIsts.txt 文件中给我一个错误,说它找不到我的镜像 cpp 文件之一。我已将所有代码插入到项目中的相应文件和头文件中,并将头文件和 cpp 文件添加到 CMake 列表文件中的相应位置。
CMake 中的错误: """" CMakeLists.txt:129 (add_executable) 处的 CMake 错误: 找不到源文件: 来源/效果/mirrorrighteffect.cpp
尝试过的扩展 .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx
我仔细检查了所有文件都在正确的目录中,所以我不知道问题是什么。
#------- headers --------
set (HEADERS
sources/mainwindow.h
sources/easypaintenums.h
sources/imagearea.h
sources/datasingleton.h
sources/additionaltools.h
sources/effects/abstracteffect.h
sources/effects/negativeeffect.h
sources/effects/grayeffect.h
sources/effects/binarizationeffect.h
sources/effects/customeffect.h
sources/effects/effectwithsettings.h
sources/effects/gammaeffect.h
sources/effects/mirrorrighteffect.h <<<-----------My file
sources/effects/mirrordowneffect.h <<<-----------My file
sources/effects/gaussianblureffect.h
sources/effects/sharpeneffect.h
sources/undocommand.h
sources/widgets/toolbar.h
sources/widgets/colorchooser.h
sources/widgets/palettebar.h
sources/widgets/palettebutton.h
sources/widgets/shortcutedit.h
sources/widgets/abstracteffectsettings.h
sources/widgets/customfiltersettings.h
sources/widgets/sharpenfiltersettings.h
sources/widgets/gaussianblurfiltersettings.h
sources/widgets/imagepreview.h
sources/dialogs/resizedialog.h
sources/dialogs/settingsdialog.h
sources/dialogs/textdialog.h
sources/dialogs/effectsettingsdialog.h
sources/instruments/abstractinstrument.h
sources/instruments/abstractselection.h
sources/instruments/selectioninstrument.h
sources/instruments/pencilinstrument.h
sources/instruments/lineinstrument.h
sources/instruments/eraserinstrument.h
sources/instruments/rectangleinstrument.h
sources/instruments/ellipseinstrument.h
sources/instruments/fillinstrument.h
sources/instruments/sprayinstrument.h
sources/instruments/magnifierinstrument.h
sources/instruments/colorpickerinstrument.h
sources/instruments/curvelineinstrument.h
sources/instruments/textinstrument.h)
#------- sources --------
set (SOURCES
sources/main.cpp
sources/mainwindow.cpp
sources/imagearea.cpp
sources/datasingleton.cpp
sources/additionaltools.cpp
sources/effects/abstracteffect.cpp
sources/effects/negativeeffect.cpp
sources/effects/grayeffect.cpp
sources/effects/binarizationeffect.cpp
sources/effects/effectwithsettings.cpp
sources/effects/gammaeffect.cpp
sources/effect/mirrorrighteffect.cpp <<<-----------My file
sources/effect/mirrordowneffect.cpp <<<-----------My file
sources/undocommand.cpp
sources/widgets/toolbar.cpp
sources/widgets/colorchooser.cpp
sources/widgets/palettebar.cpp
sources/widgets/palettebutton.cpp
sources/widgets/shortcutedit.cpp
sources/widgets/customfiltersettings.cpp
sources/widgets/sharpenfiltersettings.cpp
sources/widgets/gaussianblurfiltersettings.cpp
sources/widgets/imagepreview.cpp
sources/dialogs/resizedialog.cpp
sources/dialogs/settingsdialog.cpp
sources/dialogs/textdialog.cpp
sources/dialogs/effectsettingsdialog.cpp
sources/instruments/abstractinstrument.cpp
sources/instruments/abstractselection.cpp
sources/instruments/selectioninstrument.cpp
sources/instruments/pencilinstrument.cpp
sources/instruments/lineinstrument.cpp
sources/instruments/eraserinstrument.cpp
sources/instruments/rectangleinstrument.cpp
sources/instruments/ellipseinstrument.cpp
sources/instruments/fillinstrument.cpp
sources/instruments/sprayinstrument.cpp
sources/instruments/magnifierinstrument.cpp
sources/instruments/colorpickerinstrument.cpp
sources/instruments/curvelineinstrument.cpp
sources/instruments/textinstrument.cpp)
【问题讨论】:
sources/effects/mirrorrighteffect.h
和 sources/effect/mirrorrighteffect.cpp
是文件夹 sources/effects
还是 sources/effect
?我相信你有一个错字。
哦,哇。我不敢相信我错过了。我想有时只是需要另一双眼睛。谢谢你接听。
OT:我通常在每个子文件夹中创建一个 CMakeLists.txt 并附加到源变量或为每个子文件夹创建一个静态库。
【参考方案1】:
你似乎在sources/———>>>effect<<<——-/mirrorrighteffect.cpp
中有错字。
我相信一定是sources/effects/mirrorrighteffect.cpp
。
【讨论】:
以上是关于CMake 找不到源文件,即使它位于正确的位置 [关闭]的主要内容,如果未能解决你的问题,请参考以下文章
C++ 可执行文件在运行时找不到库,即使它位于 /usr/lib 中(在 Linux 上)