2012年11月14日 星期三

x64中加入OnTimer發生error C2440....

http://www.viva64.com/en/k/0011/
如網頁中介紹
x64中OnTimer參數改成UINT_PTR
所以使用afx_msg void OnTimer(UINT nIDEvent) 就會出錯
把UINT改成UINT_PTR即可

2012年10月23日 星期二

error LNK2005 (把sqlite3.c加到vs2010 x64project中碰到的問題)

一開始的error是要拿掉precompile header
拿掉之後跑出

Error 1 error LNK2005: "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z) already defined in LIBCMTD.lib(new.obj) C:\Users\Xerxes\Documents\Visual Studio 2010\Projects\test1\test1\uafxcwd.lib(afxmem.obj)
Error 2 error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPEAX@Z) already defined in LIBCMTD.lib(dbgdel.obj) C:\Users\Xerxes\Documents\Visual Studio 2010\Projects\test1\test1\uafxcwd.lib(afxmem.obj)
Error 3 error LNK2005: "void * __cdecl operator new[](unsigned __int64)" (??_U@YAPEAX_K@Z) already defined in LIBCMTD.lib(new2.obj) C:\Users\Xerxes\Documents\Visual Studio 2010\Projects\test1\test1\uafxcwd.lib(afxmem.obj)
Error 4 error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPEAX@Z) already defined in LIBCMTD.lib(delete2.obj) C:\Users\Xerxes\Documents\Visual Studio 2010\Projects\test1\test1\uafxcwd.lib(afxmem.obj)
Error 5 error LNK1169: one or more multiply defined symbols found C:\Users\Xerxes\Documents\Visual Studio 2010\Projects\test1\x64\Debug\test1.exe 1

問題在CRT和MFC library都有new delete等function, 需要先link MFC libray再link CRT


Solution:
Properties -> Linker --> Input --> Additional dependencies
加入;uafxcwd.lib;LIBCMTD.lib
順序不可以改變

參考: http://support.microsoft.com/kb/148652

2012年10月12日 星期五

使用CArray碰到error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'

http://www.cppblog.com/hlong/archive/2007/11/20/37015.html
問題大概像是文章內所述,
照他的寫法也可以compile過,
不過看不太懂為什麼要這樣改?

2012年8月16日 星期四

Windows Shell Extension 問題 (project form VC6 to VS2008)

最近在看windows shell programming
因為範例project是用vc6, 我的環境是用vs2008
轉換時有些地方需要修改
碰到的部分問題記錄在這篇

 1. Error PRJ0019 : A tool returned an error code from "Performing registration" 
以系統管理員身份執行vs2008再compile就成功了

 2. error C2259: 'ATL::CComObject' : cannot instantiate abstract class 
似乎是method的prototype有變更 
GetCommandString(UINT , UINT , UINT* , LPSTR , UINT) 
第一個參數要改成UINT_PTR


2012年6月4日 星期一

Android sensor porting筆記

Android sensor內部讀寫流程大概可以分為兩部份,
一個是寫入loop, 不斷讀取sensor值寫入pipe, 開機就會自動執行.
另一個是讀取的loop, 在註冊listener後才會在sensor資料改變時做讀取,
在程式中寫入loop流程如圖:
讀取流程:


2012年4月30日 星期一

There is a problem with the configuration server. (/usr/libexec/gconf-sanity-check-2 exited with status 256)

使用ubuntu到一半發現某些程式無法開啟有異常,
想說重新開機試試, 沒想到一開機就跑出
There is a problem with the configuration server. (/usr/libexec/gconf-sanity-check-2 exited with status 256)


只有root可以使用圖型桌面登入, 其餘使用者登入皆會出現上述錯誤.
上網查了一下發現可能是不小心改了/tmp的權限造成其他使用者無法讀寫,
sudo chmod 777 /tmp 之後就能正常進入桌面了


reference: http://forums.fedoraforum.org/showthread.php?t=208427

2012年3月20日 星期二

md5sum

md5sum可用來檢查檔案是否相同, 例如比對下載的壓縮檔.
$ md5sum  PAPAPA.tgz 會顯示
a0b162e26281ef097ee8b39b8690a8c2  PAPAPA.tgz
將上面output前面那段文字和網頁提供的md5碼比對是否相同即可

也可以把整段output存在文字檔(例如sum.txt)中,
然後把要比對的檔案和文字檔放在同一個資料夾
$ md5sum -c sum.txt
執行後會利用output後面的檔名去找檔案去比對md5sum
比對成功就顯示 PAPAPA.tgz: OK
重點是檔名必須要和產生md5sum時一樣才能用此方法

2012年2月14日 星期二

Build Android ICS source code問題

build沒幾秒就跑出下面error訊息:
============================================
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.
 
Your version is: java version "1.6.0_22".
The correct version is: Java SE 1.6.
 
Please follow the machine setup instructions at
  http://source.android.com/source/download.html
*****************************************************
build/core/main.mk:131: *** stop. Stop.

問題似乎是不允許使用openjdk, 在main.mk中判斷如果抓到openjdk字串就停止,
解決方式是使用sun/oracle的jdk版本,
使用sudo apt-get install sun-java6-jdk重新抓一個版本
再使用update-alternatives --config java/javac改成剛抓的版本再BUILD一次即可