Cygwin

From WxWiki
Revision as of 14:11, 19 October 2018 by Tierra (talk | contribs) (Text replacement - "http://docs.wxwidgets.org" to "https://docs.wxwidgets.org")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

To set up wxWidgets using Cygwin

  • install Cygwin. In addition to the default, you will need to select the following packages:
    • gcc-g++
    • make
  • get wx sources in one way or another
    • Probably you want to go here. Don't download the Windows Installer. choose either current stable (v2.8.12) or development version (v2.9.3). You may be able to pick between wxMSW, wxGTK or wxX11. (I want wxMSW, i don't know about the others.)
    • alternatively, get sources via svn:
svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH wxWidgets-2.8

Possibly you have to want to adjust the url above to the latest stable release. See:[1]

  • there are more detailed install instructions for cygwin inside the sources you just downloaded, see
wxWidgetsX.Y/docs/msw/install.txt

Below an abbreviated version of the process described in install.txt

  • For cygwin the Linux (typical) install instructions should suffice but you will need to have X11 support (precomplied binaries and lib are available from Cygwin setup/updates)
 cd /path/to/downloaded/wxWidgetsX.Y
 mkdir build-debug
 cd build-debug
 ../configure --with-X11
 make
 make install
 # you may need to also export the path to the libraries
 echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib" >> ~/.bashrc
  • For cygwin you may also want to use "configure" with some additional parameters.
 cd $WXWIN
 mkdir build-debug
 cd build-debug
 ../configure --with-msw --enable-debug --enable-debug_gdb --disable-shared
 make
 make install # This step is optional, see note (6) below.
 cd samples/minimal
 make -f minimal.unx
 ./minimal.exe 
  • configure parameters (examples)
 ./configure --with-msw --enable-debug --enable-debug_gdb --disable-shared
 ./configure --with-msw --enable-unicode
  • use --disable-precomp-headers if Cygwin doesn't support precompiled headers
  • see './configure --help' for more details; configure is not covered here
  • 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.
  • If you don't configure with "--disable-shared", you will be unable to compile contrib libraries.
  • Make sure the path to wxWidget directory doesn't contain a space or the make will fail.
  • see [2] try: export LIBS=" -lGL"
  • After you successfully configured you need to make wxWidgets:
 make

How can you see if you are successful? install.txt tells which files should be build (see 'Where Compiled Files are Stored'). In subdir 'lib' named after compiler, e.g. cygwxbase294u_gcc_custom-4.dll

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 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

Alternatively, compile samples/minimal as indicated above.

To generate Win32 applications rather than console apps

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.