MinGW編譯wxWidgets問題

其實利用MinGW編譯wxWidgets是一件挺簡單的事情,可是最近在編譯的時候遇到一些問題,並找到解決方案,所以在此分享一下我的經驗。編譯出錯的緣由是因爲安裝了MSYS的緣故。

錯誤信息相似於以下的結果:

if not exist ../../lib/gcc_lib/mswud/wx mkdir ../../lib/gcc_lib/mswud/wxshell

process_begin: CreateProcess(NULL, -c "if not exist ../../lib/gcc_lib/mswud/wx mkdir ../../lib/gcc_lib/mswud/wx", ...) failed.canvas

make (e=2)less




產生錯誤的緣由是由於安裝了MSYS後,利用Make命令會首先執行MSYS中的SHELL命令,從而會致使編譯錯誤,對於這種狀況,能夠修改 $(WX)/build/msw目錄中的makefile.gcc文件,使其默認採用CMD命令行。
makefile.gcc修改前:  SHELL := $(COMSPEC)
makefile.gcc修改後:  C:\WINDOWS\system32\CMD.exe     (該路徑爲實際的CMD.exe的路徑)



==============================================================================
最後仍是順便說一下MinGW編譯wxWidgets的流程:
1 下載源代碼 http://www.wxwidgets.org/downloads/
2 修改 $(WX)/build/msw 目錄中的makefile.gcc文件  (可選)
3 修改 $(WX)/build/msw 目錄中的congfig.gcc文件 ()
4 在控制檯進入到 $(WX)/build/msw 目錄中,執行 mingw32-make -f makefile.gcc

注: $(WX)表示你下載的源代碼解壓後的路徑


對編譯過程還不明白的能夠查看官方說明:



==============================================================================
congfig.gcc文件
# =========================================================================
#     This configuration file was generated by
#     Bakefile 0.2.9 (http://www.bakefile.org)
#     Beware that all changes made to this file will be overwritten next
#     time you run Bakefile!
# =========================================================================


# -------------------------------------------------------------------------
# These are configurable options:
# -------------------------------------------------------------------------

# Compiler flags to link shared library 
LINK_DLL_FLAGS ?= -shared

# Compiler flags to link loadable module 
LINK_MODULE_FLAGS ?= -shared

# C compiler 
CC = gcc

# C++ compiler 
CXX = g++

# Standard flags for CC 
CFLAGS ?= 

# Standard flags for C++ 
CXXFLAGS ?= 

# Standard preprocessor flags (common for CC and CXX) 
CPPFLAGS ?= 

# Standard linker flags 
LDFLAGS ?= 

# The C preprocessor 
CPP ?= $(CC) -E

# What type of library to build? [0,1]
SHARED ?= 1

# Build wxUniversal instead of native port? [0,1]
WXUNIV ?= 0

# Compile Unicode build of wxWidgets? [0,1]
UNICODE ?= 1

# Use MSLU library when building Unicode version. [0,1]
MSLU ?= 0

# Type of compiled binaries [debug,release]
BUILD ?= release

# Should debugging info be included in the executables? The default value
# "default" means that debug info will be included if BUILD=debug
# and not included if BUILD=release. [0,1,default]
DEBUG_INFO ?= default

# Should __WXDEBUG__ be defined? The default value "default" means that it will
# be defined if BUILD=debug and not defined if BUILD=release. [0,1,default]
DEBUG_FLAG ?= default

# Multiple libraries or single huge monolithic one? [0,1]
MONOLITHIC ?= 1

# Build GUI libraries? [0,1]
USE_GUI ?= 1

# Build wxHTML library (USE_GUI must be 1)? [0,1]
USE_HTML ?= 1

# Build multimedia library (USE_GUI must be 1)? [0,1]
USE_MEDIA ?= 1

# Build wxXRC library (USE_GUI must be 1)? [0,1]
USE_XRC ?= 1

# Build wxAUI library (USE_GUI must be 1)? [0,1]
USE_AUI ?= 1

# Build wxRichTextCtrl library (USE_GUI must be 1)? [0,1]
USE_RICHTEXT ?= 1

# Build OpenGL canvas library (USE_GUI must be 1)? [0,1]
USE_OPENGL ?= 0

# Build ODBC database classes (USE_GUI must be 1)? [0,1]
USE_ODBC ?= 0

# Build quality assurance classes library (USE_GUI must be 1)? [0,1]
USE_QA ?= 0

# Enable exceptions in compiled code. [0,1]
USE_EXCEPTIONS ?= 1

# Enable run-time type information (RTTI) in compiled code. [0,1]
USE_RTTI ?= 1

# Enable threading in compiled code. [0,1]
USE_THREADS ?= 1

# Enable wxCairoContext for platforms other than Linux/GTK. [0,1]
USE_CAIRO ?= 0

# Link with gdiplus.lib? (Needed for wxGraphicsContext, will also set wxUSE_GRAPHICS_CONTEXT) [0,1]
USE_GDIPLUS ?= 0

# Is this official build by wxWidgets developers? [0,1]
OFFICIAL_BUILD ?= 0

# Use this to name your customized DLLs differently 
VENDOR ?= custom

#  
WX_FLAVOUR ?= 

#  
WX_LIB_FLAVOUR ?= 

# Name of your custom configuration. This affects directory
# where object files are stored as well as the location of
# compiled .lib files and setup.h under the lib/ toplevel directory. 
CFG ?= 

# Compiler flags needed to compile test suite in tests directory. If you want
# to run the tests, set it so that the compiler can find CppUnit headers. 
CPPUNIT_CFLAGS ?= 

# Linker flags needed to link test suite in tests directory. If you want
# to run the tests, include CppUnit library here. 
CPPUNIT_LIBS ?= 

# Version of C runtime library to use. You can change this to
# static if SHARED=0, but it is highly recommended to not do
# it if SHARED=1 unless you know what you are doing. [dynamic,static]
RUNTIME_LIBS ?= dynamic

# Set the version of your Mingw installation here.
#     "3" ...... this is for Mingw 2.0 or newer (comes with gcc3)
#     "2.95" ... for Mingw 1.1 or any of the older versions [3,2.95]
GCC_VERSION ?= 3
相關文章
相關標籤/搜索