Search Google

Saturday, November 24, 2007

gcc還是在Linux下用會比較好

最近在Windows上使用MinGW時遇到幾個挫敗:
1. 總是無法順利呼叫叫做SendInput的Win32 API,總是給我類似這樣的錯誤訊息

C:\Documents and Settings\user\My Documents\code\api_sendinput>make
gcc -I. -IC:\MinGW\include -g -mwindows -o api_sendinput.exe api_sendinput.o -
Wall -LC:\MinGW\lib -Lc:\MinGW\bin -luser32
api_sendinput.o: In function `main':
C:/Documents and Settings/user/My Documents/code/api_sendinput/api_sendinput.c:5
3: undefined reference to `SendInput'
collect2: ld returned 1 exit status
make: *** [api_sendinput.exe] Error 1

2. 今天寫了一個程式parse掃毒程式產生的Log file,執行後跟沒執行一樣,於是使用gdb除錯,進入gdb後我用set args給參數之後還沒設break point就馬上開始執行,結果跑出來的卻是正確的結果,同樣的src code丟到lab server上編譯過後執行的再正常不過。

所以gcc還是比較適合在Linux下使用。。。
話說從gcc轉換到VC++原來還是有overhead,原本gcc編譯的好好的code丟到VC++裡編譯的結果執行總是怪怪的,經過研究之後把#define換成宣告global variable才正常,而且有時候使用#define還會產生error,使用linux的list.h時就是一個例子。

現在電腦中的開發環境亂成一團,自己都快搞糊塗了,看來下星期再回覆重新來過吧!

No comments: