OSDN Git Service

Build on MinGW/Windows now succeeds
[molby/Molby.git] / how_to_build
1 --------------------------------------------------------
2   How to build Molby
3   Version 0.6.5
4   Toshi Nagata
5 --------------------------------------------------------
6
7 Building Molby is somewhat complicated because you need static libraries of wxWidgets and Ruby (and CLAPACK in Windows). The procedures are described below for each platform.
8 In the following, $MOLBY represents the Molby source directory, which should reside within a directory like $HOME/Development or something like that.
9
10 (1) Mac OS X
11
12 (i) Xcode, gfortran
13
14 Install Xcode, if you have not done so yet. The Xcode project included in the source distribution is for Xcode 3.0 and later, thus you need Mac OS 10.5.
15
16 To build AmberTools, you need to have gfortran installed. The author uses a binary build available at the "R for Mac OS X" website (http://r.research.att.com/tools/, gfortran-4.2.3.dmg).
17
18 We need static linking of libgfortran.a. For that purpose, the following modification should be done after installation of gfortran.
19
20 % cd /usr/local/lib
21 % sudo cp libgfortran.a libgfortran-static.a  #  Copy as a different name
22 % sudo strip -S libgfortran-static.a  #  Remove the symbols
23 % sudo ranlib libgfortran-static.a
24
25 The last two lines are necessary to avoid linker warnings saying "Can't find atom for N_GSYM stabs."
26
27 (ii) wxWidgets
28
29 Get wxWidgets-3.0.0 from the wxWidgets official page in sourceforge.net (http://sourceforge.net/projects/wxwindows/files/). Newer versions may work, but they are not tested.
30
31 Unpack wxWidgets-3.0.0.tar.gz. Move the resulting directory wxWidgets-3.0.0 to $MOLBY/../.
32
33 Build wxWidgets. The commands will be as follows. Take care of the configure options.
34 $ cd $MOLBY/../wxWidgets-3.0.0
35 $ mkdir osx-build
36 $ cd osx-build
37 $ ../configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk --with-macosx-version-min=10.5 --enable-universal_binary=ppc,i386 --disable-shared --with-opengl --enable-monolithic
38 $ make
39 (It will take quite long. You do not need to do "sudo make install".)
40
41 (iii) Ruby
42
43 Get ruby-2.0.0-p353.tar.gz, unpack it, and move the resulting directory ruby-2.0.0-p353 to $MOLBY/../.
44 $ cd $MOLBY/../ruby-2.0.0-p353
45 $ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -O2' ./configure --prefix=$PWD/osx-build --with-arch=i386,ppc --disable-shared --with-ext=date --disable-install-rdoc
46 $ make && make install
47
48 The osx-build directory contains lib (which contains libruby-static.a) and include (which contains include files). (There are also bin and share directories, but these are not used for building Molby.)
49 $ make clean  #  Remove configure files and intermediates; the osx-build directory remains intact
50
51 ---- Old description (ruby 1.8.7) ----
52 Get ruby-1.8.7-p160.tar.gz from the Molby source distribution site. Unpack it, and move the resulting directory ruby-1.8.7-p160 to $MOLBY/../. Rename it to ruby-1.8.7-static (or make a symbolic link).
53 $ cd $MOLBY/..
54 $ mv somewhere/ruby-1.8.7-p160.tar.gz ./
55 $ tar xvzf ruby-1.8.7-p160.tar.gz
56 $ ln -s ruby-1.8.7-p160 ruby-1.8.7-static
57
58 If you want to place ruby-1.8.7-static in another place (and/or another name) than $MOLBY/../, you will need to change the build settings in Xcode.
59
60 Patch the Ruby source.
61 $ cd $MOLBY/../ruby-1.8.7-static
62 $ patch --backup -p1 < $MOLBY/ruby-1.8.7-p160-tn.patch
63 ($MOLBY is the location of the Molby source.)
64
65 Build Ruby with --disable-shared option.
66 $ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -arch ppc -O2' ./configure --disable-shared --disable-thread
67 $ make
68 ---- end old description (ruby 1.8.7) ----
69
70 (iv) FFTW
71
72 Get fftw-3.3.2.tar.gz, unpack it, and move the resulting directory fftw-3.3.2 to $MOLBY/../. $ cd $MOLBY/../fftw-3.3.2
73 $ ./configure --prefix=$PWD/osx-build --disable-fortran CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -O2"
74 $ make && make install  #  sudo is not necessary
75 $ ./configure --prefix=$PWD/osx-ppc-build --disable-fortran CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch ppc -O2"
76 $ make && make install  #  sudo is not necessary
77 $ cd osx-build/lib
78 $ mv libfftw3.a libfftw3.i386.a
79 $ lipo -create libfftw3.i386.a ../../osx-ppc-build/lib/libfftw3.a -output libfftw3.a
80 ranlib libfftw3.a
81
82 (v) Build on Xcode
83
84 Open xcode-build/Molby.xcodeproj, and build. Note that there are two configurations, Debug and Release. In the "Release" build, the Ruby scripts update_version.rb and Documents/makedoc.rb are executed before compilation; update_version.rb modifies the version strings in the source files (by looking up the file Version), and makedoc.rb creates the HTML docments in the doc directory.
85
86 (2) Windows
87
88 The Windows binary is built by using tdm-gcc/msys. If you use VC++ or Cygwin, you need to help yourself. I use Windows only occasionally, so there may be errors and misunderstandings in the following descriptions. Feedback is welcome!
89
90 (i) MinGW, MSYS, gfortran
91
92 Install msys and tdm-gcc. The author uses msys-1.0.11, tdm-gcc-4.7.1-2, and gcc-4.7.1-tdm-1-fortran.tar.lzma.
93 Read instructions carefully in installing tdm-gcc. 
94 In installing msys-1.0.11, please make sure findutils is installed. Otherwise, find.exe of Windows is invoked from make and cause strange errors.
95
96 (ii) wxWidgets
97
98 Get wxWidgets-3.0.0 from the wxWidgets official page in sourceforge.net (http://sourceforge.net/projects/wxwindows/files/). Newer versions may work, but they are not tested.
99
100 Unpack wxWidgets-3.0.0.tar.gz. Move the resulting directory wxWidgets-3.0.0 to $MOLBY/../.
101
102 Build wxWidgets. The commands will be as follows. Take care of the configure options.
103 $ cd $MOLBY/../wxWidgets-3.0.0
104 $ mkdir msw-build
105 $ cd msw-build
106 $ ../configure --with-msw --with-opengl --disable-shared --with-libjpeg=builtin --with-zlib=builtin --enable-monolithic
107 $ make
108 (It will take quite long. You do not need to do "sudo make install".)
109
110 (iii) Ruby
111
112 Get ruby-2.0.0-p353.tar.gz, unpack it, and move the resulting directory ruby-2.0.0-p353 to $MOLBY/../.
113 $ cd $MOLBY/../ruby-2.0.0-p353
114
115 If you use gcc 4.6 or later, comment out the following line in cygwin/GNUmakefile.in
116 #  DLLWRAP += -mno-cygwin
117 (gcc 4.x deprecates the -mno-cygwin option, and from 4.6 it causes 'unrecognized option' error.)
118
119 $ ./configure --prefix=$PWD/msw-build --disable-shared --with-ext=date --disable-install-rdoc --with-static-linked-ext
120 $ make && make install
121
122 The msw-build directory contains lib (which contains libmsvcrt-ruby200-static.a and libmsvcrt-rubuy200.a) and include (which contains include files). (There are also bin and share directories, but these are not used for building Molby.)
123 $ make clean  #  Remove configure files and intermediates; the msw-build directory remains intact
124
125 --- Old description (ruby 1.8.7) ---
126 Get ruby-1.8.7-p160.tar.gz from the Molby source distribution site. Unpack it, and move the resulting directory ruby-1.8.7-p160 to $HOME. Rename it to ruby-1.8.7-static.
127 $ cd $HOME
128 $ mv somewhere/ruby-1.8.7-p160.tar.gz ./
129 $ tar xvzf ruby-1.8.7-p160.tar.gz
130 $ mv ruby-1.8.7-p160 ruby-1.8.7-static
131
132 Patch the Ruby source.
133 $ cd $HOME/ruby-1.8.7-static
134 $ patch --backup -p1 < $MOLBY/ruby-1.8.7-p160-tn.patch
135 ($MOLBY is the location of the Molby source.)
136
137 Build Ruby with --disable-shared option.
138 $ ./configure --disable-shared --disable-thread
139 $ make
140
141 (iv) CLAPACK
142
143 Get clapack-3.1.1.1.tar.gz from the CLAPACK official site (http://www.netlib.org/clapack/) and unpack it. (clapack-3.2.1 may cause trouble because it uses symbolic links.)
144 $ cd $MOLBY/..
145 $ mv somewhere/clapack-3.1.1.1.tgz ./
146 $ tar xvzf clapack-3.1.1.1.tgz
147
148 Patch the clapack source.
149 $ patch -p0 <$MOLBY/clapack-3.1.1.1-mingw.patch
150
151 Build CLAPACK.
152 $ cd CLAPACK-3.1.1.1
153 $ make
154
155 In my case, uninit.c caused an error. It turned out that float.h in GCC needed modification. In c:/tdm-gcc-32-471/lib/gcc/mingw32/4.7.1/include/float.h, a line "#include_next <float.h>" was inserted just before the last "#endif".
156
157 Modify libf2c.a, so that the 'main' entry does not interfere the main program.
158 $ cd F2CLIBS
159 $ cp libf2c.a libf2c_nomain.a
160 $ ar d libf2c_nomain.a main.o
161 $ cd ..
162
163 Copy the library and header files to CLAPACK-3.1.1.1/lib
164 $ mkdir lib
165 $ cp F2CLIBS/libf2c_nomain.a lib
166 $ cp blasMinGW.a lib/libblasMinGW.a
167 $ cp lapackMinGW.a lib/liblapackMinGW.a
168
169 (v) FFTW
170
171 Get fftw-3.3.2.tar.gz and unpack it. Move the resulting directory fftw-3.3.2 to $MOLBY/../. $ ./configure --prefix=$PWD/msw-build --disable-fortran CFLAGS="-O2"
172 $ make
173 $ make install  #  sudo is not necessary
174
175 (vi) Inno Setup 5
176
177 Install Inno Setup 5 (http://www.jrsoftware.org/isinfo.php). This is necessary to create the Molby Installer.
178
179 (vii) Build
180
181 Now you can start building Molby! Go to the project directory and do make.
182 $ cd somewhere/Molby/msw-build
183 $ make
184 $ make setup  #  To make the installer
185
186
187 2010.1.21.
188 2010.1.31. Added notice on AmberTools1.3
189 2010.4.29. Update description for MinGW/MSYS
190 2011.8.3.  Added notice on static linking of libgfortran for Mac
191 2012.11.23. Added notice on FFTW
192
193 Toshi Nagata