我通常在Ubuntu上工作,使用CMake和本地环境。我的项目编译并运行良好。现在我改成OSX和首先的编译QCustomPlot当我收到一些警告:如何为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
这里有什么问题? (使用一个多平台的开发环境,我没想到任何丢失的文件,组件或类似的问题。)
编辑:这里去制造它
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>
)
我真的很高兴,如果之前/之后/改为/ in_addition_to downvoting,你会留下评论,为什么。 – katang
我没有downvote,但我认为你应该提供有关错误的更多细节:运行“make VERBOSE = 1”而不是“make”来查看链接到的库。特别是寻找Qt5Core,它应该是包含qt_assert_x的一个。你能用qmake成功构建一些东西吗?例如,QCustomPlot示例?警告是没有什么可担心的;它建议使用在C++ 11中引入的重写说明符。但我想QCustomPlot保持与旧C++的兼容性。如果你不需要C++ 11,那么'set(CMAKE_CXX_STANDARD 98)'应该删除警告。 – pepan