Caffe: gflag编译出现问题汇总
1. 使用Unicode字符集:
出現問題
E:\CodeBase\ML\Caffe\ThirdPartySrc\gflags-master\src\gflags.cc(1340): error C2664: 'BOOL PathMatchSpecW(LPCWSTR,LPCWSTR)' : cannot convert argument 1 from 'const char *' to 'LPCWSTR'
E:\CodeBase\ML\Caffe\ThirdPartySrc\gflags-master\src\gflags.cc(1340): error C2664: 'BOOL PathMatchSpecW(LPCWSTR,LPCWSTR)' : cannot convert argument 1 from 'const char *' to 'LPCWSTR'
????????? Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
?????? Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
?E:\CodeBase\ML\Caffe\ThirdPartySrc\gflags-master\src\gflags.cc(1341): error C2664: 'BOOL PathMatchSpecW(LPCWSTR,LPCWSTR)' : cannot convert argument 1 from 'const char *' to 'LPCWSTR'
E:\CodeBase\ML\Caffe\ThirdPartySrc\gflags-master\src\gflags.cc(1341): error C2664: 'BOOL PathMatchSpecW(LPCWSTR,LPCWSTR)' : cannot convert argument 1 from 'const char *' to 'LPCWSTR'
2.使用多字符集:
出現問題:
?gflags.obj : error LNK2019: unresolved external symbol __imp_PathMatchSpecA referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::`anonymous namespace'::CommandLineFlagParser::ProcessOptionsFromStringLocked(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum google::FlagSettingMode)" (?ProcessOptionsFromStringLocked@CommandLineFlagParser@?A0x2a9c2311@google@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@W4FlagSettingMode@3@@Z)
E:\CodeBase\ML\Caffe\ThirdPartySrc\gflags-sol\lib\Release\gflags_static.lib : fatal error LNK1120: 1 unresolved externals
gflags.obj : error LNK2019: unresolved external symbol __imp_PathMatchSpecA referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl google::`anonymous namespace'::CommandLineFlagParser::ProcessOptionsFromStringLocked(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum google::FlagSettingMode)" (?ProcessOptionsFromStringLocked@CommandLineFlagParser@?A0x2a9c2311@google@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@W4FlagSettingMode@3@@Z)
E:\CodeBase\ML\Caffe\ThirdPartySrc\gflags-sol\lib\Release\gflags_nothreads_static.lib : fatal error LNK1120: 1 unresolved externals
無法定位的外部函數????
3.出現此問題參考文章:Google開源命令行參數解析庫gflags
查閱資料發現是沒有鏈接上shlwapi.lib,而shlwapi.lib是已經被廢棄的庫;鏈接上shlwapi.lib庫后再次編譯鏈接就OK了。
考慮到shlwapi.lib和gflags庫都是靜態庫,因此可以在生成gflags庫時鏈接上shlwapi.lib,這樣在應用程序中就不用額外地再鏈接上shlwapi.lib了。
另外需要注意的是,在VS【屬性】-【調試】中設置的原始命令行參數argv[]中表示字符串內容不僅僅是設置的相應字符串,他會在字符串前加上工程路徑名,而gflags中就沒有了工程路徑名,設置的多少就是多少。
解決方法:
??????? 在linker里面添加 ShLwApi.Lib
然后配置:static 為靜態庫;配置 gflag為動態庫;
4. 出現
?????? error LNK2001: unresolved external symbol __DllMainCRTStartup@12
解決方法:??????? 添加:msvcrt.lib
5.關于編譯glog
????? glog依然使用了gflag,也需要引用 ShLwApi.Lib 庫
總結
以上是生活随笔為你收集整理的Caffe: gflag编译出现问题汇总的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: realme真我C51渲染图曝光!采用刘
- 下一篇: matepad2023柔光版和matep