試圖調試一些鏈接器錯誤,我打開/ VERBOSE,我試圖弄清楚輸出。我發現我真的不知道如何閱讀它。如何閱讀詳細的VC++鏈接器輸出
例如:
1>Compiling version info
1>Linking...
1>Starting pass 1
1>Processed /DEFAULTLIB:mfc80.lib
1>Processed /DEFAULTLIB:mfcs80.lib
1>Processed /DEFAULTLIB:msvcrt.lib
1>Processed /DEFAULTLIB:kernel32.lib
1>Processed /DEFAULTLIB:user32.lib
....
1>Processed /DEFAULTLIB:libgslcblasMD.lib
1>Searching libraries
1> Searching V:\Src\Solutions\\..\..\\Common\Win32\Lib\PlxApi.lib:
1> Searching ..\..\..\..\out\win32\release\lib\camerageometry.lib:
1> Searching ..\..\..\..\out\win32\release\lib\geometry.lib:
1> Found "public: __thiscall VisionMap::Geometry::Box2d::operator class VisionMap::Geometry::Box2DInt(void)const " ([email protected]@[email protected]@[email protected]@XZ)
1> Referenced in FocusDlg.obj
1> Loaded geometry.lib(Box2d.obj)
1>Processed /DEFAULTLIB:CGAL-vc80-mt.lib
1>Processed /DEFAULTLIB:boost_thread-vc80-mt-1_33_1.lib
這是怎麼回事嗎?
我想我明白這一點:
1>Processed /DEFAULTLIB:libgslcblasMD.lib
1>Searching libraries
1> Searching V:\Src\Solutions\\..\..\\Common\Win32\Lib\PlxApi.lib:
1> Searching ..\..\..\..\out\win32\release\lib\camerageometry.lib:
1> Searching ..\..\..\..\out\win32\release\lib\geometry.lib:
1> Found "public: __thiscall VisionMap::Geometry::Box2d::operator class VisionMap::Geometry::Box2DInt(void)const " ([email protected]@[email protected]@[email protected]@XZ)
1> Referenced in FocusDlg.obj
1> Loaded geometry.lib(Box2d.obj)
它試圖找到上述操作,這是什麼地方使用FocusDlg.cpp的實施,並發現它在geometry.lib。
但是1>Processed /DEFAULTLIB:libgslcblasMD.lib
是什麼意思?什麼決定了符號解析的順序?爲什麼在處理libgslcblasMD.lib
這是第三方庫時加載這個特殊符號?還是我讀錯了?
似乎鏈接器正在瀏覽項目各種對象文件中引用的符號,但我不知道按什麼順序。然後它搜索項目使用的靜態庫 - 通過項目引用,顯式導入和自動默認庫導入;但它是按照這樣的順序進行的,這對我來說似乎是任意的。
當它找到一個符號,例如在geometry.lib後,它將繼續以找到相同的lib一堆其他的符號:
1> Searching V:\Src\Solutions\\..\..\\Common\Win32\Lib\PlxApi.lib:
1> Searching ..\..\..\..\out\win32\release\lib\camerageometry.lib:
1> Searching ..\..\..\..\out\win32\release\lib\geometry.lib:
1> Found "public: __thiscall VisionMap::Geometry::Box2d::operator class VisionMap::Geometry::Box2DInt(void)const " ([email protected]@[email protected]@[email protected]@XZ)
1> Referenced in FocusDlg.obj
1> Loaded geometry.lib(Box2d.obj)
1>Processed /DEFAULTLIB:CGAL-vc80-mt.lib
1>Processed /DEFAULTLIB:boost_thread-vc80-mt-1_33_1.lib
1> Found "public: __thiscall VisionMap::Geometry::Box2DInt::Box2DInt(int,int,int,int)" ([email protected]@[email protected]@[email protected]@Z)
1> Referenced in FocusDlg.obj
1> Referenced in ImageView.obj
1> Referenced in geometry.lib(Box2d.obj)
1> Loaded geometry.lib(Box2DInt.obj)
1> Found "public: virtual __thiscall VisionMap::Geometry::Point3d::~Point3d(void)" ([email protected]@[email protected]@[email protected])
1> Referenced in GPSFrm.obj
1> Referenced in MainFrm.obj
1> Loaded geometry.lib(Point3d.obj)
1> Found "void __cdecl VisionMap::Geometry::serialize<class boost::archive::binary_oarchive>(class boost::archive::binary_oarchive &,class VisionMap::Geometry::Point3d &,unsigned int)" ([email protected][email protected]@[email protected]@@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected])
1> Referenced in GPSFrm.obj
1> Referenced in MainFrm.obj
1> Loaded geometry.lib(GeometrySerializationImpl.obj)
但後來,由於某種原因,進而以找到在其他庫中定義的符號,並稍後返回幾何圖形(一堆)。
很顯然,它不是在做「查看幾何圖形並加載項目中引用的每個符號,然後繼續到其他庫」。但是我不清楚是什麼符號查找的順序。
在鏈接器工作開始時處理所有這些庫的處理是什麼,但沒有找到從它們加載的任何符號?這個項目是否真的不使用msvcrt.lib
,kernel32.lib
?似乎不太可能。
所以基本上我正在尋找破譯鏈接器操作中的基礎順序。