C ++ CMAKE谓词没有这样的文件

时间:2016-08-22 09:39:47

标签: c++ qt boost cmake

首先,错误日志:

-- Boost version: 1.59.0
-- Success!
-- Could NOT find Freetype (missing:  FREETYPE_LIBRARY) (found version "2.6.3")
-- LOADING OS --Windows--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Gianluca/.CLion2016.2/system/cmake/generated/mcdu-57fe38f9/57fe38f9/Debug
[  1%] Automatic moc for target untitled
[  1%] Built target untitled_automoc
[  2%] Building CXX object CMakeFiles/untitled.dir/main.cpp.obj
[  3%] Building CXX object CMakeFiles/untitled.dir/mainwindow.cpp.obj
[  4%] Building CXX object CMakeFiles/untitled.dir/gldisplay.cpp.obj
[  7%] Building CXX object CMakeFiles/untitled.dir/svg/svg.cpp.obj
[  7%] Building CXX object CMakeFiles/untitled.dir/svg/svgfont.cpp.obj
[  8%] Building CXX object CMakeFiles/untitled.dir/svg/svgstring.cpp.obj
[ 11%] Building CXX object CMakeFiles/untitled.dir/ht1000scriptmanager.cpp.obj
[ 11%] Building CXX object CMakeFiles/untitled.dir/ht1000widgetfactory.cpp.obj
CMakeFiles\untitled.dir\build.make:149: recipe for target 'CMakeFiles/untitled.dir/svg/svg.cpp.obj' failed
In file included from C:\Work\PolitecProductions\mcdu\svg\svg.cpp:1:0:
C:\Work\PolitecProductions\mcdu\svg\svg.h:14:48: fatal error: boost/algorithm/string/predicate.hpp: No such file or directory
 #include <boost/algorithm/string/predicate.hpp>
                                                ^
compilation terminated.
In file included from C:\Work\PolitecProductions\mcdu\svg\svgstring.cpp:3:0:
C:\Work\PolitecProductions\mcdu\svg\./svg.h:14:48: fatal error: boost/algorithm/string/predicate.hpp: No such file or directory
 #include <boost/algorithm/string/predicate.hpp>
                                                ^
compilation terminated.
mingw32-make.exe[2]: *** [CMakeFiles/untitled.dir/svg/svg.cpp.obj] Error 1
mingw32-make.exe[2]: *** Waiting for unfinished jobs....
In file included from C:\Work\PolitecProductions\mcdu\svg\svgfont.cpp:2:0:
C:\Work\PolitecProductions\mcdu\svg\./svg.h:14:48: fatal error: boost/algorithm/string/predicate.hpp: No such file or directory
 #include <boost/algorithm/string/predicate.hpp>
                                                ^
compilation terminated.
CMakeFiles\untitled.dir\build.make:199: recipe for target 'CMakeFiles/untitled.dir/svg/svgstring.cpp.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/untitled.dir/svg/svgstring.cpp.obj] Error 1
CMakeFiles\untitled.dir\build.make:174: recipe for target 'CMakeFiles/untitled.dir/svg/svgfont.cpp.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/untitled.dir/svg/svgfont.cpp.obj] Error 1
CMakeFiles\untitled.dir\build.make:249: recipe for target 'CMakeFiles/untitled.dir/ht1000widgetfactory.cpp.obj' failed
In file included from C:\Work\PolitecProductions\mcdu\ht1000widgetfactory.cpp:1:0:
C:\Work\PolitecProductions\mcdu\./ht1000widgetfactory.h:5:25: fatal error: QScriptEngine: No such file or directory
 #include <QScriptEngine>
                         ^
compilation terminated.

更多http://pastebin.com/72ySYdVd

这是我的实际CMakeLists

cmake_minimum_required(VERSION 3.6)
project(mcdu)


#### Boost Check Version
find_package(Boost REQUIRED)
if(Boost_FOUND)
    message(STATUS "Success!")
endif()
#### Qt5
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Script REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(FREETYPE)
set(QT_LIBRARIES Qt5::Widgets Qt5::Core Qt5::OpenGL Qt5::Core Qt5::Script)


set( CMAKE_AUTOMOC ON )  
ADD_DEFINITIONS(${QT_DEFINITIONS})
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage ")
add_definitions("-std=c++11")


# Find includes in corresponding build directories
include_directories(
        ${BOOST}
        ${FREETYPE}
        ${Qt5Widgets_INCLUDE_DIRS}
        -lopengl32 -lglu32 -luser32
)

if (WIN32)
    message(STATUS "LOADING OS --Windows--")
    include_directories(
    ${BOOST}/lib32-msvc-14.0 -libboost_timer-vc140-mt-gd-1_59 -libboost_log-vc140-mt-gd-1_59 -libboost_log_setup-vc140-mt-gd-1_59
    ${FREETYPE}/objs/vc2010/Win32/ -lfreetype263d
    )
endif ()


#Source Files
set(SOURCE_FILES
        src files. Cut to be short

#Header Files
set(HEADER_FILES
        header files. Cut to be short
        )

#Add Forms
QT5_WRAP_UI(FORM_FILES
        .ui files
        )


add_executable(untitled ${SOURCE_FILES} ${HEADER_FILES} ${FORM_FILES})

更多http://pastebin.com/uGf3SHUn

所以在svg.h下,include如下: #include <boost/algorithm/string/predicate.hpp>

我有MSVC2015和BOOST + FREETYPE环境。变量被添加到系统和Clion。如果我从QT构建它,我只会得到predicate.hpp错误。

这是QT PRO文件

QT += core gui script opengl

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = mcdu
TEMPLATE = app

DEFINES += WIN
DEFINES += OGLFT_NO_SOLID
DEFINES += OGLFT_NO_QT
DEFINES += TEST

INCLUDEPATH += $$(BOOST)
INCLUDEPATH += $$(FREETYPE)/include
INCLUDEPATH += status
INCLUDEPATH += systems
INCLUDEPATH += svg
INCLUDEPATH += displays

CONFIG += debug

win32 {
    DEFINES += WINDOWS
    LIBS += -lopengl32 -lglu32 -luser32
    LIBS += -L$$(BOOST)/lib32-msvc-14.0 -libboost_timer-vc140-mt-gd-1_59 -libboost_log-vc140-mt-gd-1_59 -libboost_log_setup-vc140-mt-gd-1_59
    LIBS += -L$$(FREETYPE)/objs/vc2010/Win32/ -lfreetype263d
}

linux {
    message("Build for Linux")
    DEFINES += LINUX
    DEFINES += BOOST_LOG_DYN_LINK
    LIBS += -lGLU
    LIBS += -lfreetype
    LIBS += -L/home/RINF/rogosz/source/boost_1_59_0/stage/lib -lboost_timer -lboost_log -lboost_log_setup -lboost_system -lboost_thread -lboost_filesystem
}

SOURCES += src files: cut to be short

HEADERS  += header files. cut to be short

FORMS    += form files. cut to be short

1 个答案:

答案 0 :(得分:0)

opacity: 0

find_package(Boost REQUIRED) # ... # Find includes in corresponding build directories include_directories( ${BOOST} ${FREETYPE} ${Qt5Widgets_INCLUDE_DIRS} -lopengl32 -lglu32 -luser32 ) 设置的变量(包含Boost头文件的路径)名为find_package( Boost ... ),而不是Boost_INCLUDE_DIRS

除非FREETYPE打破模式,否则也应该是BOOST

那里有什么链接器指令(FREETYPE_INCLUDE_DIRS)?

-lopengl32 -lglu32 -luser32

相当困惑。这甚至意味着什么?您使用命令if (WIN32) message(STATUS "LOADING OS --Windows--") include_directories( ${BOOST}/lib32-msvc-14.0 -libboost_timer-vc140-mt-gd-1_59 -libboost_log-vc140-mt-gd-1_59 -libboost_log_setup-vc140-mt-gd-1_59 ${FREETYPE}/objs/vc2010/Win32/ -lfreetype263d ) endif () ,但看起来好像您试图在此处提供链接器指令?添加链接依赖性是通过include_directories() ...

完成的

即使您要使用正确的命令,也不会给链接器指令(target_link_libraries()),但列出链接目标,最好是各种-lfreetype263d调用提供的目标,即{{1 (不是find_package())和${Boost_LIBRARIES}(不是${BOOST})。

此外:

${FREETYPE_LIBRARIES}

这些是特定于编译器的选项,如果您使用的是Visual Studio,则不会浮动您的船。使用${FREETYPE}set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage ") add_definitions("-std=c++11") 检查您正在使用的编译器。