-
Notifications
You must be signed in to change notification settings - Fork 19
Build MinGW with OSX
I'm using OracleBox on a Mac Mini but you could do in anything that has a VM capability. I'm not going to discuss how to set up the VM in any detail. Do Not blindly copy and paste these instructions. The top view is to create a linux guest vm, get the VM and networking up. Build Ruby, build Shoes, package Shoes with an installer. There are lots of options and there are notes at the end you might consider.
Mint is a Ubuntu Xenial based distro because I like apt-get and synaptic and Xfce because I don't like Unity or Gnome desktops.
- Install Guest Additions
- reboot
- software updater
- reboot
- build-essential
- libgtk-3-dev
- libyaml-dev
- librsvg2-dev
- libjpeg-dev
- libgif-dev
- git
git clone or network mount
- mkdir ~/Projects
- sudo apt-get install nfs-common
- sudo mount -t nfs 192.168.1.2:/Projects /home/ccoupe/Projects
- Test
- modify /etc/fstab
192.168.1.2:/Projects /home/ccoupe/Projects nfs auto,noatime,nolock,bg,intr ,tcp,actimeo=1800 0 0
- reboot and test
Download Missing libraries
apt-get install libgdbm-dev, libssl-dev, libreadline-dev libcurl4-openssl-dev
mkdir ~/src; cd ~/src
mv ../Downloads/ruby-2.3.7.tar.gz .
tar xf ruby-2.3.7.tar.gz
cd ruby-2.3.7
./configure --enable-shared --enable-load-relative --disable-install-doc
make
sudo make install
Close terminal. Open new terminal to get updates to $PATH
$ which ruby
/usr/local/bin/ruby
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-linux]
get the latest Ruby gems, untar it (in src)
mv Downloads/rubygems-2.7.7.tgz src/
cd src
tar xf rubygems-2.7.7.tgz
cd rubygems-2.7.7
$ sudo ruby setup.rb --no-document
$ gem -v
2.7.7
There are two ways to move forward. The first method applies to using a NFS mount which has the Shoes source and prebuilt gems. The second method doesn't use a network drive.
$ cd Projects/shoes3
ccoupe@mintvm ~/Projects/shoes3 $ rake -T
mkdir -p minlin
rake bsd:setup:freebsd # freebsd 11.1 x86_64
rake bsd:setup:minbsd # freebsd minimal
rake build # Build using your OS setup
rake clean # Remove any temporary products
rake clobber # Remove any generated file
rake default # Same as `rake build'
rake install # Not Recommended! Install min Shoes in your ~/....
rake linux:setup:lin64 # chroot build for x86_64 (64bit linux)
rake linux:setup:minlin # build non-portable linux
rake linux:setup:rpi # Native Raspberry Pi build - 2+
rake linux:setup:xwin7 # Cross compile with MingW32
rake osx:setup:xmavericks # Setup to build Shoes for 10.9+ from 10.10+
rake osx:setup:yosemite # Setup to build Shoes for 10.10+ from 10.10
rake package # Package Shoes for distribution
rake version # create VERSION.txt
rake win32:setup:msys2 # Windows build with msys2
rake win32:setup:win7 # Winodws build with devkit
ccoupe@mintvm ~/Projects/shoes3 $
Good enough for now. Shoes wants some gems installed in that Ruby before we can build Shoes or we can
point to a location that has the gems already compiled for us. We tell the Shoes build where things are with
a custom.yaml - since we want to build the lin64 target we need a lin64-custom.yaml
$ more lin64-custom.yaml
Ruby: /usr/local
Deps:
Gemloc: /home/ccoupe/Projects/gems/rb23
Extloc: /home/ccoupe/Projects/gems/rb23
Exts:
Gems:
InclGems:
- chipmunk-6.1.3.4
- sqlite3-1.3.13
- mini_portile2-2.2.0
- nokogiri-1.8.0
- rb-readline-0.5.4
- byebug-9.0.6
- ffi-1.9.18
# picky needs:
- activesupport-5.1.2
- concurrent-ruby-1.0.5
- i18n-0.8.6
- multi_json-1.12.1
- picky-4.31.3
- rack_fast_escape-2009.06.24
- thread_safe-0.3.6
- tzinfo-1.2.3
- url_escape-2009.06.24
- yajl-ruby-1.3.0
# typhoeus
- ethon-0.10.1
- typhoeus-1.1.2
Debug: false
Deprecations: false
Notice how the yaml tells the Rakefile where ruby is (/usr/local/) and where the gems are and what version numbers of the gem to use. You can get a copy here Please, get a copy! Yes, there is another way to get the gems but its more work for you. [link to that method here]
Once everything is in place
$ rake linux:setup:lin64
mkdir -p lin64
Native complile for x86_64 Linux
echo 'TGT_ARCH=lin64' >build_target
$ rake
That simple rake defaults to rake build and you'll get a long list of compiling output and hopefully no fatal errors. The build is in the lin64 directory. Test by starting Shoes with lin64/shoes
For this example I'm going to clone Shoes from github. Create a directory to hold Shoes and friends - lets call it 'proj'
$ mkdir proj
$ cd proj
$ git clone https://github.com/shoes/shoes3.git
Lets take a shortcut and copy the prebuilt gems and extract them.
$ wget https://shoes.mvmanila.com/public/gems/lin64gems.tgz
$ tar xf lin64gems.tgz
$ ls
lin64gems.tgz rb23 shoes3
rb23/built/lin64/ has the gems. Now we need to tell the Shoes build system where we have things. cd into proj and create a file named lin64-custom.yaml with this content
Ruby: /usr/local
Deps:
Gemloc: /home/ccoupe/proj/rb23
Extloc: /home/ccoupe/proj/rb23
Exts:
Gems:
InclGems:
- chipmunk-6.1.3.4
- sqlite3-1.3.13
- mini_portile2-2.2.0
- nokogiri-1.8.0
- rb-readline-0.5.4
- byebug-9.0.6
- ffi-1.9.18
# picky needs:
- activesupport-5.1.2
- concurrent-ruby-1.0.5
- i18n-0.8.6
- multi_json-1.12.1
- picky-4.31.3
- rack_fast_escape-2009.06.24
- thread_safe-0.3.6
- tzinfo-1.2.3
- url_escape-2009.06.24
- yajl-ruby-1.3.0
# typhoeus
- ethon-0.10.1
- typhoeus-1.1.2
Debug: false
Deprecations: false
Obviously you would set Ruby: and GemLoc: and Extloc: to where you put them. Not see if rake is working and pick your build target.
$ rake -T
rake bsd:setup:freebsd # freebsd 11.1 x86_64
rake bsd:setup:minbsd # freebsd minimal
rake build # Build using your OS setup
rake clean # Remove any temporary products
rake clobber # Remove any generated file
rake default # Same as `rake build'
rake install # Not Recommended! Install min Shoes in your ~/....
rake linux:setup:lin64 # chroot build for x86_64 (64bit linux)
rake linux:setup:minlin # build non-portable linux
rake linux:setup:rpi # Native Raspberry Pi build - 2+
rake linux:setup:xwin7 # Cross compile with MingW32
rake osx:setup:xmavericks # Setup to build Shoes for 10.9+ from 10.10+
rake osx:setup:yosemite # Setup to build Shoes for 10.10+ from 10.10
rake package # Package Shoes for distribution
rake version # create VERSION.txt
rake win32:setup:msys2 # Windows build with msys2
rake win32:setup:win7 # Winodws build with devkit
$ rake linux:setup:lin64
Native complile for x86_64 Linux
echo 'TGT_ARCH=lin64' >build_target
Now do the build with a simple
$ rake
mkdir -p lin64
setup: dir=/home/ccoupe/proj/shoes3
copy_gems dir=/home/ccoupe/proj/shoes3 x86_64-linux
Copying prebuilt gem /home/ccoupe/proj/rb23/built/lin64/chipmunk-6.1.3.4
Lib copy = lib
Copying prebuilt gem /home/ccoupe/proj/rb23/built/lin64/sqlite3-1.3.13
Lib copy = lib
Copying prebuilt gem /home/ccoupe/proj/rb23/built/lin64/mini_portile2-2.2.0
...
...
...
...
new_link: arg=lin64/shoes
gcc -o lin64/shoes-bin lin64/tmp/main.o -Llin64 -lshoes -Llin64 -lgif -ljpeg -rdynamic -Wl,-export-dynamic -L/usr/local/lib -lruby -L/usr/lib/x86_64-linux-gnu -lrt -ldl -lcrypt -lm -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 /usr/lib/x86_64-linux-gnu/librsvg-2.so
echo 'cd "$OLDPWD"
LD_LIBRARY_PATH=$APPPATH $APPPATH/shoes-bin "$@"' >> lin64/shoes
echo 'cd "$OLDPWD"
LD_LIBRARY_PATH=$APPPATH gdb $APPPATH/shoes-bin "$@"' >> lin64/debug
That's the beginning and end snips of lots of terminal output. Run shoes with
$ lin64/shoes
You have Shoes!
This must be done on a Linux system (or Linux VM guest). In theory, Homebrew on OSX can do it but you'll be sorry if you go down that path. This process is very similar to building Shoes for Linux except we need Windows cross compilers, a windows Ruby, the 'dreaded dependencies' libraries, the pre-built gems and NSIS cross-installer.
sudo apt-get install gcc-mingw-w64
That's the debian/ubuntu name.
This can be a pain in the behind to build from source. Fortunately you can download one and the dreaded deps.
https://shoes.mvmanila.com/public/shoesdeps/mingw-deps.tgz
It's a big file (109MB) so it's going take some time. Expand the tar ball. tar xf mingw-deps.tgz
- that creates a mingw directory so cd mingw
and ls
~/proj/mingw $ ls
bin etc include lib libexec man README.txt ruby234 share ssl
These are even harder to build from source and it takes a long time (days?) Use the pre-built setup above. Sadly, you have do some cleanup/prep on the pkgconfig files in a few minutes.
~/proj $ wget https://shoes.mvmanila.com/public/gems/win7gems.tgz
~/proj $ tar xf win7gems.tgz
~/proj $ ls
lin64gems.tgz mingw mingw-deps.tgz rb23 shoes3 win7gems.tgz
~/proj $ ls rb23/built/
lin64 win7
Hmm. we want an xwin7. Easy. cd to rb23/built and cp -R win7 xwin7
If you forget to do this, the build will fail early on try to copy something that doesn't exist. You'll notice it.
Lets craft a xwin7-custom.yaml to tell the build system where things are stored. cd into shoes3 and create a xwin7-custom.yaml with contents:
Deps: /home/ccoupe/proj/mingw
Ruby: /home/ccoupe/proj//mingw/ruby234
Gemloc: /home/ccoupe/proj/rb23
Extloc: /home/ccoupe/proj/rb23
Gems:
InclGems:
- chipmunk-6.1.3.4
- sqlite3-1.3.13-x86-mingw32
- nokogiri-1.8.0-x86-mingw32
- mini_portile2-2.2.0
- byebug-9.0.6
- rb-readline-0.5.4
- win32-shortcut-0.3.0
- ffi-1.9.18-x86-mingw32
# picky needs:
- activesupport-5.1.2
- concurrent-ruby-1.0.5
- i18n-0.8.6
- multi_json-1.12.1
- picky-4.31.3
- rack_fast_escape-2009.06.24
- thread_safe-0.3.6
- tzinfo-1.2.3
- url_escape-2009.06.24
- yajl-ruby-1.3.0
# typhoeus
- ethon-0.10.1
- typhoeus-1.1.2
# because
#- bloopsaphone-0.4
MS-Theme: true
Debug: false
Deprecations: true
Of course, Deps:, Ruby: Gemloc: and Extloc: should point to where you stored things.
We have to cleanup/fix the pkgconfig .pc files for some hardcoded dependencies. Cd into the Deps:lib/.
cd /home/ccoupe/proj/mingw/lib
and make a backup of the pkgconfig directory. tar cf pkgconfig.tar pkgconfig
We're going to run a sed script to change those files. The backup is there in case we make a mistake.
sed -i s@/home/ccoupe/Projects/shoesdeps@/home/ccoupe/proj@ *.pc
That command replaces home/ccoupe/Projects/shoesdeps
with /home/ccoupe/proj. You want to put your Deps: location in the second part. We are not done fixing things. Ruby has .pc file that needs correcting.
cd /home/ccoupe/proj/mingw/ruby234/lib/pkgconfig` and run the same sed command (that you modified with the correct directory path)
sed -i s@/home/ccoupe/Projects/shoesdeps@/home/ccoupe/proj@ *.pc
Failure to fix this will results in fatal errors compiling - files not found kinds of errors. Don't panic - you made that backup, right? Lets try some compiling.
Remember, we're going to do the build with our linux ruby (in /usr/local) and the cross compilers and then we're going to copy from the deps, windows ruby, and gems specified in the xwin7-custom.yaml. Lets try it. Make sure the previous build is removed (clobber) setup the build
$ rake clobber
$ rake linux:setup:xwin7
mkdir -p xwin7
Deps: /home/ccoupe/proj/mingw
Cross compile for Windows MingW32
echo 'TGT_ARCH=xwin7' >build_target
$ rake
....
....
....
i686-w64-mingw32-windres -I. shoes/appwin32.rc xwin7/tmp/appwin32.o
i686-w64-mingw32-gcc -o xwin7/shoes.exe xwin7/tmp/main.o xwin7/tmp/appwin32.o -Lxwin7 -lshoes -mwindows -L/home/ccoupe/proj/mingw/bin -lgif-7 -ljpeg -llibrsvg-2 -llibffi -Wl,-export-all-symbols -L/home/ccoupe/proj/mingw/ruby234/lib -lmsvcrt-ruby230 -L/home/ccoupe/proj/mingw/lib -lcairo -L/home/ccoupe/proj/mingw/lib -lpango-1.0 -lm -lgobject-2.0 -lglib-2.0 -lintl -lgtk-3 -lgdk-3 -lfontconfig-1 -lpangocairo-1.0
strip -x xwin7/shoes.exe
i686-w64-mingw32-gcc -o xwin7/cshoes.exe xwin7/tmp/main.o xwin7/tmp/appwin32.o -Lxwin7 -lshoes -L/home/ccoupe/proj/mingw/bin -lgif-7 -ljpeg -llibrsvg-2 -llibffi -Wl,-export-all-symbols -L/home/ccoupe/proj/mingw/ruby234/lib -lmsvcrt-ruby230 -L/home/ccoupe/proj/mingw/lib -lcairo -L/home/ccoupe/proj/mingw/lib -lpango-1.0 -lm -lgobject-2.0 -lglib-2.0 -lintl -lgtk-3 -lgdk-3 -lfontconfig-1 -lpangocairo-1.0
strip -x xwin7/cshoes.exe
$
Shoes is in xwin7/shoes.exe. If ~/proj was mapped as a network drive In Windows, it should run. The rest of use need to create and installer that bundles up xwin7/* into Shoes-3.3.7-gtk3-32.exe. That would be the NSIS installer.
Debian have an nsis package you can apt-get install. Do you know if it has the unicode and large strings patches? Me neither (It appears that 'no' is the answer) What I do know is you can screw up a users system, majorly if your installer does not have those patches. I do mean major screw up. They will not be pleased.
As of 2018-Jun-21, I can't build nsis on linux. We can copy a working copy and stitch together (debian 64 only)
$ wget https://shoes.mvmanila.com/public/shoesdeps/nsis/makensis.gz
$ wget https://shoes.mvmanila.com/public/shoesdeps/nsis/usr-share-nsis.tgz
$ sudo -s
[sudo] password for ccoupe:
mintvm proj # gunzip makensis.gz
mintvm proj # chmod +x makensis
mintvm proj # cp makensis /usr/local/bin
mintvm proj # cp usr-share-nsis.tgz /usr/share/
mintvm proj # cd /usr/share/
mintvm share # tar zxf usr-share-nsis.tgz
Go back to the shoes3 directory with the built Shows for windows in xwin7/ and do 'rake package` and makensis is run (it takes a while to compress things). When finished you should have 20+MB shoes-3.3.x-gtk3-32.exe in the pkg/ directory. Copy that to your windows system or download site.
Download the source from here. I picked nsis-2.46.unicode-src.zip Oddly, or maybe not, it needs a fix or two - Scons vs SCons.
$ mkdir nsis
$ mv ~/Downloads/nsis-2.46.5-Unicode-src.zip nsis
$ cd nsis
$ unzip nsis-2.46.5-Unicode-src.zip
$ sudo apt-get install scons
$ chmod +755 *
$ mv Scons SCons
$ scons -h
$ scons SKIPSTUBS=all SKIPPLUGINS=all SKIPUTILS=all SKIPMISC=all NSIS_CONFIG_CONST_DATA=no UNICODE=yes PREFIX=/home/ccoupe/proj/nsis/nsis-2.46 install-compiler
That "should work" -- it doesn't.
[Update] Cool! https://gist.github.com/artynet/ccb10628e04492b676ed4fb97fbf6850 https://gist.github.com/artynet/188bb34cfc94acdb554d283a3502770a
Those instructions still fail for 2.46 with unicode patch but they do work for 3.03 which is very recent release. Time to move past 2.46?
- Yes you can use RVM to install the ruby used to build the xwin7 target. However, It is a Really Good Idea to build the ruby you want for inside Shoes. - that way you control whats in it. RVM to run rake, your own for the build (the custom-yaml Ruby points to the /usr/local one, not the RVM on)
RVM: you have to figure out how to pass the -C --enable-shared --enable-load-relative --no-doc
flags which almost always means 'do it again' and you have to dink with the .bashrc/.bash_profile fiends.
- Nsis Installer has it's own wiki page.`
Menu
In This Section:
- Shoes Rakefiles
- Rake files
- App.yaml secrets
- Custom.yaml
- Gems for Shoes
- Build with Vagrant
- Building Shoes on Linux
- Building Shoes on Pi2
- Mingw Dependencies
- Building Shoes on Windows
- Cross compile mingw
- OSX 10.10 Dependencies
- OSX 10.9 Dependencies
- OSX 10.6 Dependencies
- Caution Using brew 10.6
- Build-MinGW-with-OSX
- NSIS Installer for Windows
- MSYS2 cross compiling
- Cross-compile-for-arm-(raspberry)
- MXE-Dependencies
- FreeBSD and Shoes