自己遇到的BUG積累

1、用VS2005,C++使用GDAL的動態庫時,報編譯錯誤

Error 28 error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: __thiscall std::_Vector_const_iterator<struct GDALColorEntry,class std::allocator<struct GDALColorEntry> >::_Vector_const_iterator<struct GDALColorEntry,class std::allocator<struct GDALColorEntry> >(struct GDALColorEntry *,class std::_Container_base const *)" (??0?$_Vector_const_iterator@UGDALColorEntry@@V?$allocator@UGDALColorEntry@@@std@@@std@@QAE@PAUGDALColorEntry@@PBV_Container_base@1@@Z) match1.obj 

解決方法:Configuration Properties -> C/C++ -> Code Generation -> Runtime Library, make sure this is set to either "Multi-Threaded Debug DLL (/MDd)" if you are linking with the dll runtime or "Multi-Threaded Debug (/MTd)" if you are statically linking with the runtime.


2、用VS2005編譯SharpMap/Branches/0.9.5中的SharpMap.Extensions時報錯“Error103Unsafe code may only appear if compiling with /unsafe”

解決方法:在工程屬性中勾選“Allow Unsafe code”

unsafe screenshot

3、VS2008無法捕捉到斷點,調試的時候原來的斷點處顯示一個空心圓加一個右下角的警告圖標的解決方案。

今天(2013年9月18日,牢記歷史!)本來寫代碼調試得好好的,突然加了一句話以後無法調試了,原來紅紅的斷點處在調試的時候變成了空心圓加一個右下角的警告圖標,如果臨時讓斷點生效,可以選擇右鍵點擊斷點,Location,把Allow Source code to be different這個選項勾上,但是編譯的時候又提示“the source file is different from when the module was built”,雖然點確定也能過去,但是問題始終是沒有解決的,感覺應該是修改代碼以後IDE不知哪裏沒更新,導致它認爲兩份源代碼不一樣

解決方案:

Tools-Options,選中Debugging選項卡,裏面有個“Require source to exactly match...”的勾先去掉,然後稍微修改下代碼,保存後,再把勾勾上,這樣就好了。

4、VS2008在處理字符串的時候報錯“”Error 4 error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'char [1024]' to 'LPCWSTR'

這種涉及到普通字符轉換爲寬字符(W)的時候,需要在項目屬性裏Configuration Properties——General——Character Set,改爲Use Multi-Byte Character Set,這樣就不報錯了,就可以通用了。

發佈了21 篇原創文章 · 獲贊 15 · 訪問量 40萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章