Skip to content

Instantly share code, notes, and snippets.

@Coridyn
Last active September 26, 2018 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Coridyn/7b5e8069f48277584e8c to your computer and use it in GitHub Desktop.
Save Coridyn/7b5e8069f48277584e8c to your computer and use it in GitHub Desktop.
How to compile and install the sassc-ruby gem on Windows

Windows installation

This will install SassC Ruby gem on Windows.

  1. Download and install Ruby 2 (http://rubyinstaller.org/downloads/)
  2. Download and install the ruby development kit (http://rubyinstaller.org/downloads/) (for the rest of the document, assuming it's installed into c:\devkit\)
  3. Download the libdl library for Windows (https://github.com/dlfcn-win32/dlfcn-win32) Go to releases and download the most recent precompiled version.
  4. Extract the libdl package into your development kit mingw directory: e.g. extract the package (lib\ and include\) into c:\devkit\mingw\
  5. Try installing gem install sassc (might fail)
  6. If it installs successfully then try the sassc compilation test (at the bottom of this file)
  7. If failed to install properly then edit the libsass Makefile: c:\ruby2\lib\ruby\gems\2.2.0\gems\sassc-1.8.1\ext\libsass\Makefile

Edit the makefile and force it to build a static library (especially under MinGW). Set the following variables to 1:

	STATIC_ALL       ?= 1
	STATIC_LIBGCC    ?= 1
	STATIC_LIBSTDCPP ?= 1
  1. Start the dev kit command prompt: c:\devkit\msys.bat
  2. Navigate to the sassc gem directory: c:\ruby2\lib\ruby\gems\2.2.0\gems\sassc-1.8.1\ext\libsass
  3. Run make lib/libsass.so LDFLAGS="-Wall -O2" to compile the library.
  4. DONE. Try the sassc compilation test.

SASSC Compilation test

Copy and paste into sassc.rb:

require 'sassc'

# Simple scss content
data = <<-eos
$temp: red;
body {
	color: $temp;
}
eos

# Compile and print the result
result = SassC::Engine.new(data).render
puts "result=#{result}"

Then from a command prompt run:

$ ruby sassc.rb

Expected output:

result=body {
  color: red; }

Links which helped

Libsass build documentation:

Problem: ld cannot find -ldl compiler error message
Fix: steps 3 and 4, install libdl into mingw dev environment
http://stackoverflow.com/questions/12455160/using-libdl-so-in-mingw

Problem: ruby_ffi "The specified module could not be found" error
Fix: step 7, build static library with libgcc
http://ffi.github.io/ruby-ffi-archive/messages/20110430-Re_%5Bruby-ffi%5D%20need%20help%20loading%20a%20library-805.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment