毕业设计开始了,虽然具体题目没定,老师也不鸟我的邮件。
但是兵马未动,粮草先行。先把我的环境折腾完再说。
想到今后要无穷无尽的命令行。也不想写makefile。
我先用该死的autoconf搭个自动生成的框架出来:
一开始误入歧途。看了很久的autoconf的手册,也慢慢的在搭,结果始终无法吧wxwidget加进去。然后google:wxwidget autoconf
结果官方的wiki华丽丽的出来了。
囧然后就是按照官方的wiki上写了撒
先autoscan生成autoconf.scan,改成autoconf.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT(xx, 1.0, cwh5635@gmail.com)
AC_CONFIG_SRCDIR([xx.cpp])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(xx, 1.0)#这里非常关键,如果没有这一行,aclocal就不会生成aclocal.m4
# Checks for programs.
AC_PROG_CXX
# Checks for libraries.
AM_OPTIONS_WXCONFIG
reqwx=2.4.0
AM_PATH_WXCONFIG($reqwx, wxWin=1)
if test "$wxWin" != 1; then
AC_MSG_ERROR([
wxWidgets must be installed on your system.
Please check that wx-config is in path, the directory
where wxWidgets libraries are installed (returned by
'wx-config --libs' or 'wx-config --static --libs' command)
is in LD_LIBRARY_PATH or equivalent variable and
wxWidgets version is $reqwx or above.
])
fi
CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
LIBS="$LIBS $WX_LIBS"
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
上面的变量定义于wxwin.m4.
(WX_CPPFLAGS,WX_CXXFLAGS_ONLYNEWS README AUTHORS ChangeLogNEWS README AUTHORS ChangeLog
).automake第一次出错了,后来我吧wxwin.m4改名成aclocal.m4然后就成功了,如果你也出现找不到这2个东西,可以试试。
接下来是第二个重点。touch NEWS README AUTHORS ChangeLog
不使用这个的话,不会生成makefile.in
然后就是autoheader automake autoconf一路下去
makefile.am:
#sample Makefile.am
#builds two wxWidgets programs and one standard (text) c++ program
#define three output files
noinst_PROGRAMS = xx
#wxpanel definitions
#wxpanel_SOURCES = mainwxpanel.cc statictext.cc statictext.h main.h
#wxpanel_LDADD = @LIBS@
#wxpanel_CXXFLAGS = @CXXFLAGS@
xx_SOURCES = xx.cpp
xx_LDADD = @LIBS@
xx_CXXFLAGS = @CXXFLAGS@
#togglebutton definitions
#togglebutton_SOURCES = togglebutton.cc main.cc statictext.h main.h togglebutton.h
#togglebutton_LDADD = @LIBS@
#toggelbutton_CXXFLAGS = @CXXFLAGS@
#cpexample definitions (note, use defaults, no definition necessary)
#cpexample_SOURCES = cpexample.cc
然后./configure
make编译成功。over~