OpenSCAD User Manual/Building on Windows: Difference between revisions

From Wikibooks, open books for an open world
Jump to navigation Jump to search
[unreviewed revision][unreviewed revision]
Content deleted Content added
Line 170: Line 170:
*Copy "scripts/installer.nsi" to the "release" directory.
*Copy "scripts/installer.nsi" to the "release" directory.
*Right-click on the file and compile it with NSIS. It will spit out a nice, easy installer. Enjoy.
*Right-click on the file and compile it with NSIS. It will spit out a nice, easy installer. Enjoy.

== Relevant links ==

*[http://www.cgal.org/Manual/3.4/doc_html/installation_manual/Chapter_installation_manual.html CGAL compilation manual] from cgal.org
*[http://rocklinux.net/pipermail/openscad/2011-May/thread.html Windows Binaries], OpenSCAD mailing list, 2011 May

Revision as of 02:33, 18 July 2011

I managed to compile OpenSCAD on 04.May.2011. I'll try to document the necessary steps. The build is as static as reasonable, with no external DLL dependencies that are not shipped with Windows

Downloads

start by downloading:

Installing

  • Install Visual Studio
    • No need for siverlight or mssql express
    • You can use a virtual-CD program like MagicDisc to mount the ISO file and install without using a CD
  • Install QT
    • Install to default location C:\Qt\4.7.2\
  • Install Git
    • Install this fully integrated into the shell despite the big red letters warning you not to.
  • Install Cmake
    • Check the 'Add cmake to the system path for the current user' checkbox
    • Install to default location C:\Program Files\CMake 2.8
  • Install Boost
    • Select the VC++ 9.0 vs2008 radio
    • Check the 'multithreaded static runtime' checkbox only
    • Install into C:\boost_1_46_1\
  • Install GCAL
    • Note its not a binary distribution, just an installer that installs the source.
    • No need for CGAL Examples and Demos
    • Make sure mpfr and gmp precompiled libs is checked
    • The installer wants you to put this in C:\Program Files\CGAL-3.7\ I used C:\CGAL-3.7\
    • Make sure CGAL_DIR environment checked.
  • Install MinGW
    • Make sure you select the MSYS Basic System under components
  • Extract downloaded win32_gmp_mpfr.zip file to C:\win32_gmp_mpfr\
  • Replace the mpfr and gmp .h files in CGAL with the ones from win32_gmp_mpfr
    • Delete, or move to a temp folder, all files in CGAL-3.7\auxiliary\gmp\include folder
    • Copy all the .h files in C:\win32_gmp_mpfr\gmp\Win32\Release to CGAL-3.7\auxiliary\gmp\include
    • Copy all the .h files in C:\win32_gmp_mpfr\mpfr\Win32\Release to CGAL-3.7\auxiliary\gmp\include
  • Replace the mpfr and gmp libs in CGAL with the ones from win32_gmp_mpfr
    • Delete, or move to a temp folder, all (06/20/2011 libmpfr-4.lib is needed) files in CGAL-3.7\auxiliary\gmp\lib folder.
    • Copy C:\win32_gmp_mpfr\gmp\Win32\Release\gmp.lib to CGAL-3.7\auxiliary\gmp\lib
    • Copy C:\win32_gmp_mpfr\mpfr\Win32\Release\mpfr.lib to CGAL-3.7\auxiliary\gmp\lib

To get OpenSCAD source code:

  • Open "Git Bash" (the installer may have put a shortcut on your desktop). This launches a MinGW32 command line window.
  • Type cd c: to change the current directory.
  • Type git clone git://github.com/openscad/openscad.git This will put OpenSCAD source into C:\openscad\

Where to put other files:

I put all the dependencies in C:\ so for example, extract the various .zip and .tar.gz to:

  • C:\eigen2\
  • C:\glew-1.5.8\
  • C:\OpenCSG-1.3.1\

Windows tar.gz tools include 7-zip, or the MingW shell you just installed (tar -zxvf)

The other programs should have been installed like so:

  • C:\openscad\
  • C:\boost_1_46_1\
  • C:\CGAL-3.7\

Compiling Dependencies

For compilation I use the QT Development Command Prompt

Start->Program Files->Qt by Nokia v4.7.2 (VS2008 OpenSource)->QT 4.7.2 Command Prompt

Qt

Qt needs to be recompiled to get a static C runtime build. To do so, open the command prompt and do:

configure -static -platform win32-msvc2008 -no-webkit

Configure will take several minutes to finish processing. After it is done, open up the file Qt\4.7.2\mkspecs\win32-msvc2008\qmake.conf and replace every instance of -MD with -MT. Then:

nmake

This takes a very, very long time. Have a nap. Get something to eat. On a Pentium 4, 2.8GHZ CPU with 1 Gigabyte RAM, Windows XP, it took more than 7 hours, (that was with -O2 turned off)

CGAL

cd C:\CGAL-3.7\
set BOOST_ROOT=C:\boost_1_46_1\
cmake .

This should create a CGAL.sln (solution) file. If not, try

cmake -G"Visual Studio 9 2008" . 

Now edit the CMakeCache.txt file. Replace every instance of /MD with /MT before the next step.

cmd /c vcexpress CGAL.sln /build
Substitute devenv for vcexpress if you are not using the express version.

OpenCSG

Launch Visual Express.

cd C:\OpenCSG-1.3.1
vcexpress OpenCSG.sln
Substitute devenv for vcexpress if you are not using the express version
  • Manually step through project upgrade wizard
  • Make sure the runtime library setting for OpenCSG project is set to multi-threaded
    • Open the OpenCSG project properties by clicking menu item "Project->OpenCSG Properties" (might be just "Properties")
    • Click 'Configuration Properties'
    • Select "Release" from "Configuration:" drop down menu
    • Click C/C++ -> Code Generation
    • Make sure "Runtime Library" is set to "Multi-threaded (/MT)"
    • Click hit OK
  • Make sure the runtime library setting for glew_static project is set to multi-threaded
    • In "Solution Explorer - OpenCSG" pane click "glew_static" project
    • Open the OpenCSG project properties by clicking menu item "Project->OpenCSG Properties" (might be just "Properties")
    • Select "Release" from "Configuration:" drop down menu
    • Click C/C++ -> Code Generation
    • Make sure "Runtime Library" is set to "Multi-threaded (/MT)"
    • Click hit OK
  • Close Visual Express saving changes

Build OpenCSG library.

cmd /c vcexpress OpenCSG.sln /build
Again, substitute devenv if you have the full visual studio

The cmd /c bit is needed otherwise you will be returned to the shell immediately and have to Wait for build process to complete (there will be no indication that this is happening appart from in task manager)

OpenSCAD

In the openscad directory, edit the following files:

  • In bison.pri, in the lines that say bison.commands and bison_header.commands, change "bison" to "C:\MinGW\msys\1.0\bin\bison.exe"
    • Note: 06/20/2011 I couldn't find "bison.exe" anywhere inside MinGW and instead found it in "C:\Program Files\Git\bin".
  • In flex.pri, in the line that says flex.commands, change "flex" to "C:\MinGW\msys\1.0\bin\flex.exe"
    • Note: 06/20/2011 I couldn't find "flex.exe" anywhere inside MinGW and instead found it in "C:\Program Files\Git\bin".
    • Adding "C:\Program Files\Git\bin" to the environment variable PATH would work instead of changing the *.pri files I think, but untested.

Now run the following commands:

cd C:\openscad
set INCLUDE=%INCLUDE%C:\CGAL-3.7\include;C:\CGAL-3.7\auxiliary\gmp\include;
set INCLUDE=%INCLUDE%C:\boost_1_46_1;C:\glew-1.5.8\include;C:\OpenCSG-1.3.1\include;C:\eigen2
set LIB=%LIB%C:\CGAL-3.7\lib;C:\CGAL-3.7\auxiliary\gmp\lib;
set LIB=%LIB%C:\boost_1_46_1\lib;C:\glew-1.5.8\lib;C:\OpenCSG-1.3.1\lib
qmake

Ignore the warnings.

Now run

nmake -f Makefile.Release

While this is running, open up the src directory, open the file lexer.lexer.cpp (the first stage of the build generates this file) and find the line that says

b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;

Replace it with:

b->yy_is_interactive = 0;

Wait for the nmake to end. It will likely stop with an error if you took too long to edit the files. If there is an error, just run

nmake -f Makefile.Release

again. Ignore all warnings. There will be an openscad.exe file in the release folder. Enjoy.

Building an installer

  • Download and install NSIS from http://nsis.sourceforge.net/Download
  • Put the FileAssociation.nsh macro from http://nsis.sourceforge.net/File_Association in the NSIS Include directory
  • Copy the "libraries" and "examples" directory into the "release" directory
  • (Optional) copy the .scad files from the current version of mcad (https://github.com/elmom/MCAD) into a folder called "mcad" and put that folder into the "libraries folder"
  • Copy "scripts/installer.nsi" to the "release" directory.
  • Right-click on the file and compile it with NSIS. It will spit out a nice, easy installer. Enjoy.