window下通過makefile 文件編譯C/C++源文件

scintilla下載下來的例子:
所帶4文件:
resource.h
DMApp.cxx
DMApp.rc
makefile_vc

其中
makefile_vc的文件內容:
/////////////////////////////////////////////////////////////////////////
# Make file for DMApp, a small demonstration application
# for the SciLexer DLL.
# This file should be in a directory which is a peer of the scintilla
# directory so Scintilla.h and SciLexer.h files can be found

CC = cl
RC = rc
LD = link

O = obj

PROGDEMO = DMApp.EXE

ALL:    $(PROGDEMO)

clean:
    del /q *.exe *.obj *.res

LDFLAGS = /NODEFAULTLIB:LIBC KERNEL32.lib USER32.lib GDI32.lib COMDLG32.lib WINMM.lib COMCTL32.lib ADVAPI32.lib IMM32.lib SHELL32.LIB OLE32.LIB
CXXFLAGS = /TP /MD /Ox

!IFDEF DEBUG
CXXFLAGS=$(CXXFLAGS) /Zi
LDFLAGS=/DEBUG $(LDFLAGS)
!ENDIF

.cxx.$(O):
    $(CC) /I ../scintilla/include $(CXXFLAGS) -c $*.cxx -o $@

.rc.res:
    $(RC) $*.rc
   
DMApp.o: Scintilla.h SciLexer.h resource.h

$(PROGDEMO):    DMApp.obj DMApp.res
    $(LD) DMApp.obj DMApp.res $(LDFLAGS)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

其中../scintilla/include爲scintilla包含的頭文件所在目錄

接下來

製作編譯處理文件 run.bat
---------------------------------
nmake -f makefile_vc LINK_LIB="SciLexer.lib"
PAUSE
@set PATH=/;  %path%
error_printer | tee2.5.exe result.rst
PAUSE

-----------------------------
其中 makefile_vc 爲makefile的文件名, SciLexer.lib 爲所需要的庫,如果包含多個庫可以設置成路徑目錄

運行run.bat編譯結果:

--------------------------------------------------------------------------

F:/dmapp>nmake -f makefile_vc LINK_LIB="SciLexer.lib"

Microsoft (R) Program Maintenance Utility   Version 6.00.9782.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        cl /I inc /TP /MD /Ox -c DMApp.cxx -o DMApp.obj
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

DMApp.cxx
        rc DMApp.rc
        link DMApp.obj DMApp.res /NODEFAULTLIB:LIBC KERNEL32.lib USER32.lib GDI3
2.lib COMDLG32.lib WINMM.lib COMCTL32.lib ADVAPI32.lib IMM32.lib SHELL32.LIB OLE
32.LIB
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


F:/dmapp>PAUSE
請按任意鍵繼續. . .

---------------------------------
OK!,這樣就編譯完成了!出現DMApp.exe!

 

轉自:http://www.yanfaw.com/index.php?action-viewnews-itemid-1509-php-1

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章