當我在我的C++項目中一起使用Qt(v4.7.4)和Boost(嘗試v1.47和v1.48)時,出現由包含<boost\filesystem.hpp>
的類導致的鏈接器錯誤。我只是設置了Qt,在代碼運行之前沒有任何問題。使用Qt和Boost時的鏈接器錯誤
這是錯誤消息:
... OBJ:錯誤LNK2001:無法解析的外部符號「私人:靜態類的std ::常量的codecvt * & __cdecl的boost :: filesystem3 ::路徑:: wchar_t_codecvt_facet(無效) 「(wchar_t_codecvt_facet @路徑@ filesystem3 @升壓@@ CAAAPBV $ @的codecvt GDH @ STD @@ XZ)
... OBJ:?錯誤LNK2001:無法解析的外部符號」 無效__cdecl的boost :: filesystem3 :: path_traits :: convert(char const *,char const *,class std :: basic_string,class std :: allocator> &,class std :: codecvt const &)「(?convert @ p ath_traits @ filesystem3 @ boost @@ YAXPBD0AAV?$ basic_string @ GU?$ char_traits @ G @ std @@ V $ $ allocator @ G @ 2 @@ std @@ ABV?$ codecvt @ GDH @ 5 @@ Z)
... obj:錯誤LNK2001:無法解析的外部符號「void __cdecl boost :: filesystem3 :: path_traits :: dispatch(class boost :: filesystem3 :: directory_entry const &,class std :: basic_string,class std :: allocator> & ,class std :: codecvt const &)「(?dispatch @ path_traits @ filesystem3 @ boost @@ YAXABVdirectory_entry @ 23 @ AAV?$ basic_string @ GU?$ char_traits @ G @ std @@ V $ $ allocator @ G @ 2 @@ std @@ ABV?$ codecvt @ GDH @ 6 @@ Z)
... obj:錯誤LNK2001:無法解析的外部符號「void __cdecl boost :: filesystem3 :: path_traits :: convert(unsigned short const *,unsigned簡短st * :: class std :: basic_string,class std :: allocator> &,class std :: codecvt const &)「(?convert @ path_traits @ filesystem3 @ boost @@ YAXPBG0AAV?$ basic_string @ DU?$ char_traits @ D @ std @@ V $ @分配器@ d @@ 2 STD @@ ABV $ @的codecvt GDH @ 5 @@ Z)
... EXE:?致命錯誤LNK1120:4周無法解析的外部
編輯:
Here我發現有這個問題,得出這一結論的人:
這確實是一個Qt問題。使用wchar_t作爲本機類型,您必須使用相同的編譯器開關重新編譯Qt。甚至有在 跟蹤了一個錯誤:https://bugreports.qt.io/browse/QTBUG-9617
一般情況下,你必須非常小心,不要在你的項目中混合wchar_t的 編譯器設置,因爲它們會變得不兼容。
所以我重新編譯了Qt設置/Zc:wchar_t
,但沒有顯示任何效果。我仍然得到同樣的錯誤。
你有編譯boost嗎?我不太瞭解建築的確切需求,但一些圖書館的工作。 – pezcode
是的。如果我沒有記錯的話,我已經使用'b2.exe'編譯了Visual Studio 2010。 – Pedro
可能需要重新編譯整個boost庫嗎?我不記得確切的編譯配置,但是我在編譯boost時確實沒有改變'將wchar_t作爲內建類型屬性。 – Pedro