【发布时间】:2018-05-10 11:49:09
【问题描述】:
我正在尝试使用 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 作为found here 构建库。 尽管 cmake 成功了,但 make -j8 不会做任何事情,因为在构建目录中没有创建 Makefile。 也许我在这里出错了?
感谢您的帮助...
【问题讨论】:
标签: c++ build compilation libraries