You are on page 1of 3

Cygwin - WxWiki

http://wiki.wxwidgets.org/Cygwin

Cygwin
From WxWiki
NOTICE wxWidgets has migrated to using Subversion, instructions for checkout are obsolete.

Contents
1 To set up wxWidgets using Cygwin 2 To get an executable independent of Cygwin DLL 3 To test your installation 4 To generate Win32 applications rather than console apps 5 Troubleshooting

To set up wxWidgets using Cygwin


install Cygwin (http://sources.redhat.com/cygwin/setup.exe) . In addition to the default, you will need to select the following packages: cvs gcc-g++ make login then check out wxMSW (anonymous password is anoncvs):
cvs -d :pserver:anoncvs@cvs.wxwidgets.org:/pack/cvsroots/wxwidgets login cvs -d :pserver:anoncvs@cvs.wxwidgets.org:/pack/cvsroots/wxwidgets checkout wxMSW

Alternatively, you can download the wxX11 Release (http://www.wxwidgets.org/downloads/) (don't download the Windows Installer). if compiling the cvs head fails, you should have better success with an older release:
cvs -d :pserver:anoncvs@cvs.wxwidgets.org:/pack/cvsroots/wxwidgets checkout -r WX_2_8_BRANCH wxMSW

cd wxWidgets and run the configure script with the desired parameters. Example:
./configure --with-msw --enable-debug --enable-debug_gdb --disable-shared

If compiling fails with "[wxtiff_tif_jpeg.o] Error 1", use the built-in jpeg support. Example:
./configure --with-msw --enable-debug --enable-debug_gdb --disable-shared --with-libjpeg=builtin

you may have to fix dependencies by running again setup.exe of Cygwin and installing the missing packages.

1 of 3

08-06-2012 10:17 PM

Cygwin - WxWiki

http://wiki.wxwidgets.org/Cygwin

make
make

NOTE: If you don't configure with "--disable-shared", you will be unable to compile contrib libraries. NOTE2: Make sure the path to wxWidget directory doesn't contain a space or the make will fail.

To get an executable independent of Cygwin DLL


Normally if you compile with Cygwin's GCC, any executables you create will depend on the Cygwin DLL, forcing you to distribute your application with the DLL. There is, however, a workaround. Including -mno-cygwin in CFLAGS/LDFLAGS in configure.in makes Cygwin's GCC compile and link against only native windows libs. Compiling wxWidgets apps with this option has been reported to work flawlessly - at least for wxWidgets 2.6.2. See http://www.delorie.com/howto/cygwin/mno-cygwin-howto.html for more information. See also the warning in the configure.in comments about mno-cygwin and the math library. 2.2.9 If you're using 2.2.9 with cygwin, you'll have to change line 184 of the file 'src/jpeg/jmorecfg.h' from 'typedef long int INT32;' to 'typedef int INT32;'.

2.8.0 To remove all traces of cygwin-dependence, I had to do the following (assuming you are building under bash) export CFLAGS=-mno-cygwin export CPPFLAGS=-mno-cygwin export CXXFLAGS=-mno-cygwin export LDFLAGS="-mno-cygwin -mwindows" ./configure --build=i686-pc-mingw32 --disable-precomp-headers --without-expat Note that you might be able to omit some of the above command-line options, as they were related to my particular version of cygwin (1.5.23-2) and gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) make make samples

To test your installation


Fetch this HelloWorld example here (http://www.wxwidgets.org/hworld.txt) and save it as hworld.cpp in directory ~/hworld Now compile and link it in one step:
cd ~/hworld g++ -o hworld hworld.cpp `../wxWidgets/wx-config --cxxflags --libs --debug=yes`

Test the executable:


./hworld.exe

To generate Win32 applications rather than console apps


2 of 3

08-06-2012 10:17 PM

Cygwin - WxWiki

http://wiki.wxwidgets.org/Cygwin

Include the linker flag '-mwindows' to produce a Win32 app, i.e. one which doesn't pop up a console as well as your GUI. If you are using a configure script, this can be achieved with 'export LDFLAGS=-mwindows' before you run configure.

Troubleshooting
If you get
undefined reference to `_IID_IPersistFile'

you have a library conflict, see http://cygwin.com/ml/cygwin-apps/2010-11/msg00045.html

On various forums people mention about compilation errors under Cygwin and in most cases these reports remain unsolved. If you have such problem, in majority of cases there is a conflict between Cygwin environment and other utilities/tools installed in the system. The standard PATH variable in Cygwin is constructed from windows PATH variable. Therefore, you can run utils or even compiler from for example MinGW even not knowing about it. Check the PATH environment and correct to point only onto Cygwin directories. Then do make clear and rerun whole configure-make procedure. Retrieved from "http://wiki.wxwidgets.org/Cygwin" This page was last modified on 19 April 2012, at 14:33.

3 of 3

08-06-2012 10:17 PM

You might also like