我通常在 Ubuntu 上工作,使用 CMake 和本机环境。我的项目编译并运行良好。现在我更改为 OSX,首先在编译 QCustomPlot 时收到一些警告:
QCustomPlot/include/qcustomplot.h:6007:15: warning:
'findEnd' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]
virtual int findEnd(double sortKey, bool expandedRange=true) const;
^
../QCustomPlot/include/qcustomplot.h:3830:15: note:
overridden virtual function is here
virtual int findEnd(double sortKey, bool expandedRange=true) const = 0;
我想我可以压制这个警告。但是,如果警告可能意味着真正的危险,我不喜欢压制警告。(在 Ubuntu 下,没有警告)。为什么是警告?我认为重写虚函数并不是很不寻常或危险的。
无论如何,有警告,但有 dompiles。真正的问题出现在链接上
[ 4%] Building CXX object QCustomPlot/CMakeFiles/libQCustomPlot.dir/libQCustomPlot_automoc.cpp.o
[ 5%] Linking CXX shared library libQCustomPlot.dylib
Undefined symbols for architecture x86_64:
"qt_assert_x(char const*, char const*, char const*, int)", referenced from:
QList<QCPDataRange>::at(int) const in qcustomplot.cpp.o
QList<QCPDataRange>::operator[](int) in qcustomplot.cpp.o
这里有什么问题?(由于使用的是多平台开发环境,我没想到会出现任何丢失的文件、组件或类似问题。)
编辑:这里是生成它的 CMake 文件
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5 COMPONENTS Core Widgets PrintSupport REQUIRED)
include_directories(
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Printer_INCLUDE_DIRS}
include
)
add_definitions(${Qt5Widgets_DEFINITIONS} ${Qt5Printer_DEFINITIONS})
QT5_WRAP_CPP(qcustomplot_moc include/qcustomplot.h)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} -std=c++11 -Wall")
ADD_LIBRARY(libQCustomPlot
qcustomplot.cpp
${qcustomplot_moc} # The MOC headers, generated
)
set_target_properties(libQCustomPlot
PROPERTIES OUTPUT_NAME QCustomPlot
)
target_include_directories(libQCustomPlot PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)