无法使用 XLNT 库构建 C++ 项目
Can't build C++ project with XLNT library
我正在尝试使用 MinGW g++ 在 Windows 8 下使用 XLNT-Library 构建示例项目。
该代码是在 github 文档中找到的示例代码:
#include <xlnt/xlnt.hpp>
int main()
{
xlnt::workbook wb;
xlnt::worksheet ws = wb.active_sheet();
ws.cell("A1").value(5);
ws.cell("B2").value("string data");
ws.cell("C3").formula("=RAND()");
ws.merge_cells("C3:C4");
ws.freeze_panes("B2");
wb.save("example.xlsx");
return 0;
}
我将库下载为 zip 文件,将其解压缩并将文件夹 [xlnt-master-root]\include\xlnt 复制到我的 main.cpp 所在的文件夹中,然后尝试使用这个命令:
g++ -std=c++14 -lxlnt -Ixlnt/include .\excelTest.cpp -o excelTest.exe
但这会导致以下错误:
c:/users/s/documents/myprogramms/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe:
cannot find -lxlnt
我也尝试将 [xlnt-master] 文件夹复制到 main.cpp 位置并尝试再次编译它,结果相同。
我可以用 C++ 编程,但我以前没有使用过库。
你能给我一个提示,告诉我如何正确使用和编译带有库的项目吗?
仅供参考:我还尝试使用 cmake as found here 构建库。
虽然 cmake 成功了,但 make -j8 不会做任何事情,因为在构建目录中没有创建 Makefile。
也许我在这里错了?
感谢您的帮助...
使用最新的 visual studio 2017,您可以自动构建 xlnt 库。
您可以下载以下库:
我正在尝试使用 MinGW g++ 在 Windows 8 下使用 XLNT-Library 构建示例项目。 该代码是在 github 文档中找到的示例代码:
#include <xlnt/xlnt.hpp>
int main()
{
xlnt::workbook wb;
xlnt::worksheet ws = wb.active_sheet();
ws.cell("A1").value(5);
ws.cell("B2").value("string data");
ws.cell("C3").formula("=RAND()");
ws.merge_cells("C3:C4");
ws.freeze_panes("B2");
wb.save("example.xlsx");
return 0;
}
我将库下载为 zip 文件,将其解压缩并将文件夹 [xlnt-master-root]\include\xlnt 复制到我的 main.cpp 所在的文件夹中,然后尝试使用这个命令:
g++ -std=c++14 -lxlnt -Ixlnt/include .\excelTest.cpp -o excelTest.exe
但这会导致以下错误:
c:/users/s/documents/myprogramms/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe:
cannot find -lxlnt
我也尝试将 [xlnt-master] 文件夹复制到 main.cpp 位置并尝试再次编译它,结果相同。
我可以用 C++ 编程,但我以前没有使用过库。 你能给我一个提示,告诉我如何正确使用和编译带有库的项目吗?
仅供参考:我还尝试使用 cmake as found here 构建库。 虽然 cmake 成功了,但 make -j8 不会做任何事情,因为在构建目录中没有创建 Makefile。 也许我在这里错了?
感谢您的帮助...
使用最新的 visual studio 2017,您可以自动构建 xlnt 库。
您可以下载以下库: