无法使用 XLNT 库生成C++项目

Can't build C++ project with XLNT library

本文关键字:C++ 项目 XLNT      更新时间:2023-10-16

我正在尝试使用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 xlnt 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 中编程,但我以前从未与库合作。您能给我一个提示如何正确使用和编译该项目的图书馆?

fyi:我还尝试使用CMAKE构建图书馆,如这里所示。尽管Cmake取得了成功,但Make -j8不会做任何事情,因为在构建目录中没有创建makefile。也许我在这里错了?

感谢您的帮助...

使用持续的 Visual Studio 2017 ,您可以构建 Xlnt library automatic。

您可以下载下面的库:

https://1drv.ms/f/s!3yanq3dydem1g9mtinwww7cyth