[英]Why can't I link "xlnt" library?
我搜索了SO并发现了一些类似的问题,但答案中没有任何帮助。
我绝不是一个经验丰富的c++
程序员,感觉就像我用这个库撞到了砖墙。
虽然我不想放弃,但我想学习如何去做。
我错过了一些基本的东西吗?
我构建xlnt
库的步骤:
cmake ..
xlnt
的来源Release x64
构建它示例测试代码:
#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()");
wb.save("example.xlsx");
return 0;
}
具有依赖项的项目属性:
(我也将xlnt.dll
复制到了我的项目的根目录)
尝试运行代码时出现的错误:
1>------ Build started: Project: xlnt-test, Configuration: Release x64 ------
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::exception::`vftable'" (??_7exception@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::illegal_character::`vftable'" (??_7illegal_character@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::invalid_attribute::`vftable'" (??_7invalid_attribute@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::invalid_cell_reference::`vftable'" (??_7invalid_cell_reference@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::invalid_column_index::`vftable'" (??_7invalid_column_index@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::invalid_data_type::`vftable'" (??_7invalid_data_type@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::invalid_file::`vftable'" (??_7invalid_file@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::invalid_parameter::`vftable'" (??_7invalid_parameter@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::invalid_sheet_title::`vftable'" (??_7invalid_sheet_title@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::detail::izstream::`vftable'" (??_7izstream@detail@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::key_not_found::`vftable'" (??_7key_not_found@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::missing_number_format::`vftable'" (??_7missing_number_format@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::no_visible_worksheets::`vftable'" (??_7no_visible_worksheets@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::detail::ozstream::`vftable'" (??_7ozstream@detail@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::unhandled_switch_case::`vftable'" (??_7unhandled_switch_case@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::unsupported::`vftable'" (??_7unsupported@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::detail::vector_istreambuf::`vftable'" (??_7vector_istreambuf@detail@xlnt@@6B@)
1>xlnt.exp : error LNK2001: unresolved external symbol "const xlnt::detail::vector_ostreambuf::`vftable'" (??_7vector_ostreambuf@detail@xlnt@@6B@)
1>D:\Docs\Programming\cpp\xlnt-test\x64\Release\xlnt-test.exe : fatal error LNK1120: 18 unresolved externals
1>Done building project "xlnt-test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我为你测试了这个库。 这样做后它可以工作:
MyTestApplication
)G:\\CMake\\Sources\\xlnt-master\\include
) 在调试模式下,生成的库名为xlntd.lib
(后缀为d
)
Linker -> Input
处添加..\\source\\$(Configuration)\\xlntd.lib
Debug
的调试模式..\\source\\$(Configuration)\\
为附加库目录,并将xlntd.lib
作为输入库在Release模式下,生成的库称为xlnt.lib
Linker -> Input
处添加..\\source\\$(Configuration)\\xlnt.lib
Release
在释放模式..\\source\\$(Configuration)\\
为附加库目录,并将xlnt.lib
作为输入库 dowing在此之后,它应该是OK
:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.