Difference between revisions of "Compiling in Windows"

From OSUPDOCS
Jump to navigation Jump to search
Line 21: Line 21:
The first time you download the project, you will need to install <tt>xerces</tt> in your [http://www.cygwin.com <tt>cygwin</tt>] environment (if you already have <tt>xerces</tt> installed, you can [[#Compiling in cygwin|skip to compiling]] now. Although <tt>cygwin</tt> has an option to install the <tt>xerces</tt> binary, it usually has an out-dated version. You therefore will need to download the <tt>xerces</tt> source code, build it, and install it. Since revision 274 of the <tt>nairn-mpm-fea</tt> project, the code requires <tt>xerces 3.0</tt> or newer. The procedure for <tt>xerces 3.0</tt> or newer is:
The first time you download the project, you will need to install <tt>xerces</tt> in your [http://www.cygwin.com <tt>cygwin</tt>] environment (if you already have <tt>xerces</tt> installed, you can [[#Compiling in cygwin|skip to compiling]] now. Although <tt>cygwin</tt> has an option to install the <tt>xerces</tt> binary, it usually has an out-dated version. You therefore will need to download the <tt>xerces</tt> source code, build it, and install it. Since revision 274 of the <tt>nairn-mpm-fea</tt> project, the code requires <tt>xerces 3.0</tt> or newer. The procedure for <tt>xerces 3.0</tt> or newer is:


# <a href="http://xerces.apache.org/xerces-c/download.cgi">Download the <code>xerces</code> source code</a>, which will be in a file such as <code>xerces-c-3.x.x.tar.gz</code> (with <code>x</code> being some numbers). Note that you should get the <code>.tar.gz</code> file instead of the <code>.zip</code> version because the <code>.zip</code> version has DOS files with carriage returns and line feeds (either in the source or inserted by Windows' zip methods) that may complicate compiliation. The <code>.tar.gz</code> file is also smaller.
<ol>
#Move the downloaded file to a folder such as the root <code>cygwin</code> folder, which by default is at Windows path <code>C:\cygwin\</code> (<font color="red">warning</font>: the <code>xerces</code> install will fail if the path to the folder in <code>cygwin</code> contains any spaces; if you use the recommended root folder, the path will be &quot;<code>/</code>&quot; which has no spaces and is therefore safe).
<li>[http://xerces.apache.org/xerces-c/download.cgi Download the <tt>xerces</tt> source code], which will be in a file such as <tt>xerces-c-3.x.x.tar.gz</tt> (with <tt>x</tt> being some numbers). Note that you should get the <tt>.tar.gz</tt> file instead of the <tt>.zip</tt> version because the <tt>.zip</tt> version has DOS files with carriage returns and line feeds (either in the source or inserted by Windows' zip methods) that may complicate compiliation. The <tt>.tar.gz</tt> file is also smaller.</li>
# Start a <tt>cygwin</tt> shell and and extract the files with:
cd /
gunzip xerces-c-3.x.x.tar.gz
tar xvf xerces-c-3.x.xtar
where the <tt>x</tt>'s are replaced by numbers in your downloaded file.
#Go to the new folder and configure the code with:
cd xerces-c-3.x.x
./configure LDFLAGS=-no-undefined
This step will prepare the <tt>xerces</tt> source code for building. Note: if you get error messages saying that $'\r'$ command is not found it means your files are DOS files rather than Unix files. Consult a Unix expert on how to fix them or go back to step <tt>1</tt> and get the <tt>.tar.gz</tt> file this time.
# When this configuring step is done, enter the commands
cd src
make
This step will compile <tt>xerces</tt> and save the librarys in the <tt>xerces-c-3.x.x/.libs</tt> folder.
# Finally, enter the command <tt>make install</tt> (still in the same folder). This step will install the compiled <tt>xerces</tt> libraries and needed header files in the default locations of <tt>/usr/local/lib</tt> and <tt>/usr/local/include</tt> folders, respectively.


<p><a name="cygcc"></a>You are now ready to compile the <code>nairn-mpm-fea</code> code. In a <code>cygwin</code> shell, navigate to the checked out <code>nairn-mpm-fea</code> and proceed as follows. To compile <code>NairnMPM</code> use:</p>
<li>Move the downloaded file to a folder such as the root <tt>cygwin</tt> folder, which by default is at Windows path <tt>C:\cygwin\</tt> (<font color="red">warning</font>: the <tt>xerces</tt> install will fail if the path to the folder in <tt>cygwin</tt> contains any spaces; if you use the recommended root folder, the path will be "<tt>/</tt>" which has no spaces and is therefore safe).</li>
<li>Start a <tt>cygwin</tt> shell and and extract the files with:
<pre>
cd /
gunzip xerces-c-3.x.x.tar.gz
tar xvf xerces-c-3.x.xtar</pre>
where the <tt>x</tt>'s are replaced by numbers in your downloaded file.</li>


<li>Go to the new folder and configure the code with:
<pre>
<pre>
cd nairn-mpm-fea/NairnMPM/build
cd xerces-c-3.x.x
make SYSTEM=cygwin
./configure LDFLAGS=-no-undefined
</pre>
</pre>
This step will prepare the <tt>xerces</tt> source code for building. Note: if you get error messages saying that $'\r'$ command is not found it means your files are DOS files rather than Unix files. Consult a Unix expert on how to fix them or go back to step <tt>1</tt> and get the <tt>.tar.gz</tt> file this time.
</li>
<li>When this configuring step is done, enter the commands
<pre>
cd src
make</pre>
This step will compile <tt>xerces</tt> and save the librarys in the <tt>xerces-c-3.x.x/.libs</tt> folder.</li>


<p>and to compile <code>NairnFEA</code> use:</p>
<li>Finally, enter the command "<code>make install</code>" (still in the same folder). This step will install the compiled <tt>xerces</tt> libraries and needed header files in the default locations of <tt>/usr/local/lib</tt> and <tt>/usr/local/include</tt> folders, respectively.</li>


<pre>
</ol>
cd nairn-mpm-fea/NairnFEA/build
 
make SYSTEM=cygwin
== Compiling cygwin ==
</pre>
 
You are now ready to compile the <tt>nairn-mpm-fea</tt> code. In a <tt>cygwin</tt> shell, navigate to the checked out <code>nairn-mpm-fea</code> and proceed as follows. To compile [[OSParticulas]] or [[NairnMPM]] use:
 
cd nairn-mpm-fea/NairnMPM/build
make SYSTEM=cygwin
 
and to compile [[NairnFEA]] use:


<p>All source code will be compiled and the executables will be installed in <code>nairn-mpm-fea/NairnMPM/input</code> or <code>nairn-mpm-fea/NairnFEA/input</code>, respectively. You can use an additional '<code>make install</code>' command to copy each compiled executable to your <code>~/bin</code> folder if desired.
cd nairn-mpm-fea/NairnFEA/build
</p>
make SYSTEM=cygwin


<p>If the command-line compile does not work, the most likely explanation is a problem with the <code>xerces</code> installation. You either have to install it as specified above or edit the <code>makefile</code> to recognize your custom installation. The process is documented in the <code>makefile</code> and involves editing the <code>xercesSo</code> and <code>headersPath</code> variables for your different settings. Another possible reason is a potential conflict with some <code>cygwin</code>/Windows combinations. If you get a linking error about undefined references to <code>typeinfo</code>, you have encountered a dynamic linking problem. It can be fixed by deleting the dynamic library at <code>/usr/local/lib/libserces-c.dll.a</code> and then use the '<code>make SYSTEM=cygwin</code>' command to link again. This change will cause the code to link statically. The resulting executables will be much larger but should work fine.
All source code will be compiled and the executables will be installed in <tt>nairn-mpm-fea/NairnMPM/input</tt> or <tt>nairn-mpm-fea/NairnFEA/input</tt>, respectively. You can use an additional '<tt>make install</tt>' command to copy each compiled executable to your <tt>~/bin</tt> folder if desired.
</p>


<p>Once the code is compiled, do a <a href="../running/index.html">test run</a> to verify it worked.
If the command-line compile does not work, the most likely explanation is a problem with the <tt>xerces</tt> installation. You either have to install it as specified above or edit the <tt>makefile</tt> to recognize your custom installation. The process is documented in the <tt>makefile</tt> and involves editing the <tt>xercesSo</tt> and <tt>headersPath</tt> variables for your different settings. Another possible reason is a potential conflict with some <tt>cygwin</tt>/Windows combinations. If you get a linking error about undefined references to <tt>typeinfo</tt>, you have encountered a dynamic linking problem. It can be fixed by deleting the dynamic library at <tt>/usr/local/lib/libserces-c.dll.a</tt> and then use the '<tt>make SYSTEM=cygwin</tt>' command to link again. This change will cause the code to link statically. The resulting executables will be much larger but should work fine.
</p>

Revision as of 09:50, 28 August 2013

This page explains how to compile code engines using Windows. To compile and run in Windows, you need some kind of Linux/Unix environment. The recommended option is to use cygwin and this documentation is based on its use.

Installing and Setting Up cygwin

The nairn-mpm-fea project runs well in Windows by using the cygwin system. You can check out the project, compile the code, run calculations, and visualize the results. This section page gives the step-by-step process for the required cygwin setup. This process has been verified in Windows XP, Windows Vista and Windows 7 (although you may need the latest `cygwin 1.7` for Windows 7).

  1. Download the cygwin setup.exe application and run it (to install cygwin or, if you already have cygwin installed, you still might need to install plug-ins listed below, if you do not have them already).
  2. Follow the default options until you reach the "Packages" step of the cygwin setup wizard. In that step, expand the "Devel" category and select:
  3. Next, expand the "Net" category and select:
    • openssh - ssh command for secure remote connections (optional).
  4. Finally, expand the "Editors" section and select a command-line editer (e.g., vim). Such an editor is useful because editing cygwin files with Microsoft software (_e.g._, NotePad) can seriously corrupt files by changing line endings from Unix-style line feeds to Windows style carriage returns and line feeds.

The basic `cygwin` should now be set up. You can run it to open a `cygwin` command-line window and browse your files. By the default, all `cygwin` files will be in the folder `C:\cygwin`. Your home folder will usually be at `/home/YOURUSERNAME`. You are now ready to [Download_Project download the code].

Installing xerces

The first time you download the project, you will need to install xerces in your cygwin environment (if you already have xerces installed, you can skip to compiling now. Although cygwin has an option to install the xerces binary, it usually has an out-dated version. You therefore will need to download the xerces source code, build it, and install it. Since revision 274 of the nairn-mpm-fea project, the code requires xerces 3.0 or newer. The procedure for xerces 3.0 or newer is:

  1. Download the xerces source code, which will be in a file such as xerces-c-3.x.x.tar.gz (with x being some numbers). Note that you should get the .tar.gz file instead of the .zip version because the .zip version has DOS files with carriage returns and line feeds (either in the source or inserted by Windows' zip methods) that may complicate compiliation. The .tar.gz file is also smaller.
  2. Move the downloaded file to a folder such as the root cygwin folder, which by default is at Windows path C:\cygwin\ (warning: the xerces install will fail if the path to the folder in cygwin contains any spaces; if you use the recommended root folder, the path will be "/" which has no spaces and is therefore safe).
  3. Start a cygwin shell and and extract the files with:
    cd /
    gunzip xerces-c-3.x.x.tar.gz
    tar xvf xerces-c-3.x.xtar
    where the x's are replaced by numbers in your downloaded file.
  4. Go to the new folder and configure the code with:
    cd xerces-c-3.x.x
    ./configure LDFLAGS=-no-undefined
    

    This step will prepare the xerces source code for building. Note: if you get error messages saying that $'\r'$ command is not found it means your files are DOS files rather than Unix files. Consult a Unix expert on how to fix them or go back to step 1 and get the .tar.gz file this time.

  5. When this configuring step is done, enter the commands
    cd src
    make
    This step will compile xerces and save the librarys in the xerces-c-3.x.x/.libs folder.
  6. Finally, enter the command "make install" (still in the same folder). This step will install the compiled xerces libraries and needed header files in the default locations of /usr/local/lib and /usr/local/include folders, respectively.

Compiling cygwin

You are now ready to compile the nairn-mpm-fea code. In a cygwin shell, navigate to the checked out nairn-mpm-fea and proceed as follows. To compile OSParticulas or NairnMPM use:

cd nairn-mpm-fea/NairnMPM/build
make SYSTEM=cygwin

and to compile NairnFEA use:

cd nairn-mpm-fea/NairnFEA/build
make SYSTEM=cygwin

All source code will be compiled and the executables will be installed in nairn-mpm-fea/NairnMPM/input or nairn-mpm-fea/NairnFEA/input, respectively. You can use an additional 'make install' command to copy each compiled executable to your ~/bin folder if desired.

If the command-line compile does not work, the most likely explanation is a problem with the xerces installation. You either have to install it as specified above or edit the makefile to recognize your custom installation. The process is documented in the makefile and involves editing the xercesSo and headersPath variables for your different settings. Another possible reason is a potential conflict with some cygwin/Windows combinations. If you get a linking error about undefined references to typeinfo, you have encountered a dynamic linking problem. It can be fixed by deleting the dynamic library at /usr/local/lib/libserces-c.dll.a and then use the 'make SYSTEM=cygwin' command to link again. This change will cause the code to link statically. The resulting executables will be much larger but should work fine.