[Qgis-developer] Compile QGis with the chroot

Francis Bolduc fbolduc at gmail.com
Thu Sep 21 16:47:33 EDT 2006


As requested, here is how I compiled Windows binaries with the mingw chroot.

See attached .txt
-------------- next part --------------
1 - Download and extract the chroot.
	
	wget mingw_chroot.tar.bz2
	tar -xjf mingw_chroot.tar.bz2

2 - Download QGis source in /home/user/win/source/qgis_head
	
	wget qgis-0.8.0-Preview-2-src.tar.gz
	tar -xjf qgis-0.8.0-Preview-2-src.tar.gz ./mingw_chroot/home/user/win/source/qgis_head
	
	You may need to remove reference to svnversion in the source code
		
		Makefile: remove svnversion something
		src/qgis.cpp remove ???svnversion.h and add #define ??SVNVERSION "something"
		src/main.cpp remove ???svnversion.h and add #define ??SVNVERSION "something"

3 - chroot
	
	sudo chroot mingw_chroot
	
2 - Create a replacement for pg_config.exe
	
	cd tmp
	vim pg_config.cpp
		
		#include <iostream>
		using namespace std;
		int main(int argc, char * argv[]) {
			if(argc > 1) {
				if(strcmp(argv[1],"--version") == 0) {
					cout << "PostgreSQL 8.1.3" << endl;
				} else if(strcmp(argv[1],"--libdir") == 0) {
					cout << "/home/user/win/source/pgsql/lib" << endl;
				} else if(strcmp(argv[1],"--includedir") == 0) {
					cout << "/home/user/win/source/pgsql/include" << endl;
				}
			} else {
				cout << "BINDIR = /home/user/win/source/pgsql/bin" << endl
				<< "DOCDIR = /home/user/win/source/pgsql/doc" << endl
				<< "INCLUDEDIR = /home/user/win/source/pgsql/include" << endl
				<< "PKGINCLUDEDIR = /home/user/win/source/pgsql/include" << endl
				<< "INCLUDEDIR-SERVER = /home/user/win/source/pgsql/include/server" << endl
				<< "LIBDIR = /home/user/win/source/pgsql/lib" << endl
				<< "PKGLIBDIR = /home/user/win/source/pgsql/lib" << endl
				<< "LOCALEDIR = /home/user/win/source/pgsql/share/locale" << endl
				<< "MANDIR = /home/user/win/source/pgsql/man" << endl
				<< "SHAREDIR = /home/user/win/source/pgsql/share" << endl
				<< "SYSCONFDIR = /home/user/win/source/pgsql/etc" << endl
				<< "PGXS = /home/user/win/source/pgsql/lib/pgxs/src/MAKE~WLE/pgxs.mk" << endl
				<< "CONFIGURE = '--with-openssl' '--with-perl' '--with-tcl' '--with-python' '--enable-nls' '--enable-thread-safety' '--with-krb5' '--with-includes=/mingw/include/krb5'" << endl
				<< "CC = gcc" << endl
				<< "CPPFLAGS = -I./src/include/port/win32 -DEXEC_BACKEND -I/mingw/include/krb5 -I../../../src/include/port/win32" << endl
				<< "CFLAGS = -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing" << endl
				<< "CFLAGS_SL =" << endl
				<< "LDFLAGS = -Wl,--allow-multiple-definition" << endl
				<< "LDFLAGS_SL =" << endl
				<< "LIBS = -lpgport -lintl -lssleay32 -leay32 -lcomerr32 -lkrb5_32 -lz -lwsock32 -lm  -lws2_32 -lshfolder" << endl
				<< "VERSION = PostgreSQL 8.1.3" << endl;
			}
		}
		
		
	/usr/bin/g++ pg_config.cpp -o pg_config
	mv pg_config /home/user/win/source/pgsql/bin
	
4 - Compile
	
	/bin/bash
	source /home/user/.bashrc
	
	cd /home/user/source/qgis_head
	
	./autogen.sh --prefix=$WIN/i586-mingw32msvc --target=$TARGET --host=$TARGET --build=i386-linux --with-qtdir=$WIN/qt4.1_win --with-projdir=$WIN/i586-mingw32msvc --with-gdal=$WIN/i586-mingw32msvc/bin/gdal-config  --with-geos=$WIN/i586-mingw32msvc/bin/geos-config --with-sqlite3=$WIN/i586-mingw32msvc --with-grass=$WIN/i586-mingw32msvc/grass-6.1.cvs --with-postgresql=$WIN/source/pgsql/bin
	
	/home/user/bin/winmake -f Makefile.win
	
	If some compilation error happen, you may have to manually build some sub-directories
		
		example, missing providers for a plugin:
			cd src/providers/
			/home/user/bin/winmake -f Makefile
	
	/home/user/bin/winmake -f Makefile install
	
5 - Distribute
	
	cd /home/user/win/i586-mingw32msvc/
	tar -cjf ../qgis.tar.gz *.dll *.exe grass/ lib/qgis/*.dll share/qgis/
	
	mv /home/user/win/qgis.tar.gz /some/destination
	


More information about the Qgis-developer mailing list