【发布时间】:2019-10-31 18:02:58
【问题描述】:
我正在尝试将 OpenXLSX 添加到我的 QtCreator 项目中,但在 this guide 之后,我似乎无法让 QtCreator 找到头文件。
QtCreator 手册提到了这个库不使用的 .lib 文件,所以我对那个指南有点迷失了。我四处搜索并尝试将 OpenXLSX/@library/@openxlsx/interfaces/c++/ 中的所有标头和源代码添加到项目树中的标头和源目录中。然而我还是得到了
exceltest.cpp:3: error: 'OpenXLSX.h' file not found
第 3 行是
#include "OpenXLSX.h"
我也试过
#include "3rdparty/OpenXLSX/@library/@openxlsx/interfaces/c++/headers/OpenXLSX.h"
3rdparty 目录与 exceltest.pro 位于同一位置
我也尝试过使用尖括号。
我不需要任何来自 OpenXLSX 的高级功能,只需读取和写入我指定为 .xlsx 或 .xls 的单元格的值。 我也没有接受使用 OpenXLSX 的想法,所以如果有人知道 excel 任何可以更好地工作的库,我对这个想法持开放态度。
编辑:所以在我将标题和源代码添加到项目树后,我的 exceltest.pro 看起来像 this。 我试着把这条线
#include "3rdparty/OpenXLSX/@library/@openxlsx/interfaces/c++/headers/OpenXLSX.h"
进入 exceltest.h 而不是 exceltest.cpp,我得到了不同的错误。 QtCreator 似乎找到了库文件,但库有问题吗?这些是错误:
In file included from J:/George/Coding/Qt/Test/exceltest/3rdparty/OpenXLSX/@library/@openxlsx/interfaces/c++/headers/XLCell.h:49:0,
from ..\exceltest\3rdparty\OpenXLSX\@library\@openxlsx\interfaces\c++\sources\XLCell.cpp:5:
J:/George/Coding/Qt/Test/exceltest/3rdparty/OpenXLSX/@library/@openxlsx/interfaces/c++/headers/XLDefinitions.h:57:35: warning: multi-character character constant [-Wmultichar]
constexpr uint32_t maxRows = 1'048'576;
^~~~~
J:/George/Coding/Qt/Test/exceltest/3rdparty/OpenXLSX/@library/@openxlsx/interfaces/c++/headers/XLDefinitions.h:59:36: warning: missing terminating ' character
constexpr uint16_t maxCols = 16'384;
^
J:/George/Coding/Qt/Test/exceltest/3rdparty/OpenXLSX/@library/@openxlsx/interfaces/c++/headers/XLDefinitions.h:59:36: error: missing terminating ' character
constexpr uint16_t maxCols = 16'384;
^~~~~
..\exceltest\3rdparty\OpenXLSX\@library\@openxlsx\interfaces\c++\sources\XLCellRange.cpp:5:10: fatal error: XLCellRange.h: No such file or directory
#include <XLCellRange.h>
^~~~~~~~~~~~~~~
compilation terminated.
..\exceltest\3rdparty\OpenXLSX\@library\@openxlsx\interfaces\c++\sources\XLCellReference.cpp:5:10: fatal error: XLCellReference.h: No such file or directory
#include <XLCellReference.h>
^~~~~~~~~~~~~~~~~~~
【问题讨论】:
-
如果“OpenXLSX.h”在 HEADERS 部分内,您是否检查过 .pro 文件?
-
第一个问题很好。欢迎。
-
@DanielB 已编辑。你能看看吗? :)
-
我不确定,但您在项目中使用子目录这一事实可能会导致问题,请参阅此线程:stackoverflow.com/questions/1176666/… 您可以尝试直接在“源”中加载所有库,然后没有任何子目录的“Headers”文件夹(位于 IDE 的左上角,您可以在其中管理项目的文件夹。)
-
@DanielB 我会试试的。
标签: c++ windows qt qt-creator qmake