我正在尝试使用 XLNT-Library 构建示例项目在 Windows 8 下使用 MinGW g++。 代码是在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 作为 found here 构建库. 虽然 cmake 成功了,但 make -j8 不会做任何事情,因为在构建目录中没有创建 Makefile。 也许我在这里错了?
感谢您的帮助...
最佳答案
关于c++ - 无法使用 XLNT 库构建 C++ 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47507557/