window下通過makefile 檔案編譯C/C++源檔案

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.