VC使用makefile小結
1,vc6產生makefile檔案:
點擊“工程”菜單下的“匯出製作檔案”,工程目錄得到xxx.mak檔案
2,命令列編譯產生
nmake -f xxx.mak
哈哈,VC自己產生的makefile檔案直接報錯:錯誤碼是U1023.
解決方案如下:
使用NMAKE手工編譯VC時報錯的一種情況介紹
按照上一篇文章講到的方法,我做了一下實驗,結果上來就報錯了,錯誤碼是U1023.
我開啟使用VC生產的.mak檔案,發現.mak檔案最開始的一些語句如下:
# Microsoft Developer Studio Generated NMAKE File, Based on Exercise08.dsp
!IF $(CFG)" == "
CFG=Exercise08 - Win32 Debug
!MESSAGE No configuration specified. Defaulting to Exercise08 - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "Exercise08 - Win32 Release" && "$(CFG)" != "Exercise08 - Win32 Debug"
!MESSAGE 指定的配置 "$(CFG)" 無效.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Exercise08.mak" CFG="Exercise08 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Exercise08 - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "Exercise08 - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF $(OS)" == "Windows_NT
NULL=
!ELSE
NULL=nul
!ENDIF
我發現的確是存在語法錯誤,而第一句就報錯,這個注釋行為什麼報錯,我沒有找到原因,反正是注釋行,也沒什麼用處,索性刪掉.
刪掉第一行後,再使用NMAKE編譯,依然報錯,還是U1023,再仔細分析一下,他媽的,不知道為什麼,VC產生的.mak檔案竟然也出現了語法錯誤
!IF $(CFG)" == " 應該是:
!IF "$(CFG)" == ""
同樣的另外一行:
!IF $(OS)" == "Windows_NT 應該是:
!IF "$(OS)" == "Windows_NT"
也就是說,刪除第一行注釋行,再改正上面的兩個錯誤,使用NMAKE編譯,就產生了和VC編譯器同樣的結果.