BroWren (browren) wrote,
BroWren
browren

  • Mood:
  • Music:

Note To Self: How to Build Windows Apps On Linux Without Using Windows

This is mostly a note to myself so I can repeat this process, but I'm posting it here so anyone else interested in doing this might benefit.


- Install the mingw* packages from the software repository.
- download the GTK Windows development package from the GTK for Windows site.
- copy the Windows GTK directories to /usr/i586-mingw32msvc/
- fix the permissions with
sudo chown -R root.root *; find . -type d -exec chmod a+x {} \;

- fix up the files in /usr/i586-mingw32msvc/lib/pkgconfig to have the right prefix:
sudo sed -i "s%^prefix=.*$%prefix=/usr/i586-mingw32msvc%" *


Next, create a GTK app in Anjuta, and tweak the files below.

configure.ac add this bit below AM_MAINTAINER_MODE:
case "${host}" in
        i[[3456789]]86-mingw32*) 
        	WIN32="yes"
			;;
        *cygwin*) 
        	WIN32="yes" 
        	;;
        *) 
        	WIN32="no" 
        	;;
esac
AM_CONDITIONAL([WIN32], test "$WIN32" = "yes")


comment out AC_PROG_LIBTOOL, and add this rule after:
AC_CHECK_TOOL( [RC], [windres], [no] )


src/Makefile.am change the project LDFLAGS to:
if WIN32
x_SOURCES += 	\
	windows.rc
	
x_LDFLAGS = \
	-Wl,--export-all-symbols,--subsystem,windows

else
x_LDFLAGS = \
	-Wl,--export-dynamic
endif


and add this rule to the end:
.rc.o:
	$(RC) -i "$<" -o "$@"


windows.rc create this and insert
id ICON "x.ico"
1 VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904E4"
    BEGIN
      VALUE "CompanyName", "x"
      VALUE "FileDescription", "x"
      VALUE "FileVersion", "1.0"
      VALUE "InternalName", "x"
      VALUE "LegalCopyright", "x"
      VALUE "OriginalFilename", "x.exe"
      VALUE "ProductName", "x"
      VALUE "ProductVersion", "1.0"
    END
  END

  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x409, 1252
  END
END


- Finally, create a Windows Debug profile in Anjuta by copying the Debug profile and adding the flag
--host=i586-mingw32msvc
to the options, and creating a new directory for the Windows build.
- Profit
Tags: cross-platform builds, linux, nerd with a purpose
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment