[英]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.