Difference between revisions of "Compile the Code Engines"

From OSUPDOCS
Jump to navigation Jump to search
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
After checking out the [http://code.google.com/p/nairn-mpm-fea/ nairn-mpm-fea] project, the next step is to compile it. All code-engine source code is standard <tt>C++</tt>  and it should be possible to compile on a variety of systems. This page gives details on some common systems. Users are responsible for compilation on other systems.
After [[Download Source Code|checking out]] the <tt>nairn-mpm-fea</tt>, the next step is to compile it. All code-engine source codes are standard <tt>C++</tt>  and it should be possible to compile on a variety of systems. This links on this page provide details on some common systems. Users are responsible for compilation on other systems. After this compiling step is completed, you can move on to documentation for [[Options for Running Calculations|running calculations]].


== MacOS X Compiling ==
== Compilation on Various Operating Systems ==


==== Using XCode ====
* [[Compiling in MacOS X]]
 
* [[Compiling in Windows]]
Most development of [[OSParticulas]] and [[NairnFEA]] is done in MacOS X and thus compiling on MacOS X is easy. The preferred method is to use XCode (a [[#MacOS X Command Line Compiling|command-line method]] is described below). A complete XCode project is located at
* [[Compiling in Linux|Command-Line Compilation]] (''e.g''., a Linux server)
 
* Compiling Using Eclipse IDE: While using <tt>Eclipse</tt> to C/C++ code compilation might be possible, it is no longer supported. Use one of the above three methods instead (depending on your OS).
nairn-mpm-fea/Common/Projects/NairnMPM.xcodeproj
 
This project is called <tt>NairnMPM</tt>, but it includes all MPM and FEA source code in two targets named <tt>NairnMPM</tt> and <tt>NairnFEA</tt>. Once [[#Compiling Xerces on MacOS X|<tt>xerces</tt> is installed]], open the <tt>NairnMPM.xcodeproj</tt> to compile the code by:</p>
 
# Select the target to compile - either <tt>NairnMPM</tt> or <tt>NairnFEA</tt>
# Choose build and they will compile and saved in XCode's derived data folder.
 
If a linking error occurs, you might have conflicting architectures between the XCode settings and the [[#Compiling Xerces on MacOS X|<tt>xerces</tt> library you installed]]. To fix this problem edit <i>both</i> the project and target settings and under the &quot;Architectures&quot; section, set the &quot;Architectures&quot; option to match the architecture you used when [[#Compiling Xerces on MacOS X|installing <tt>xerces</tt>]] or recompile <tt>xerces</tt> if needed.</li>
 
==== Compiling Xerces on MacOS X ====
 
Before you can compile and run the project, however, you will need an installed version  of the <tt>xerces</tt> library and a copy of the <tt>xerces</tt> header files. The XCode project and [[#MacOS X Command Line Compiling|command-line method]] below both assume they are installed in the default locations for MacOS X or at
 
/usr/local/lib/libxerces-c.dylib
 
for the library and at
 
/usr/local/include
 
for the header files. These can be changed if needed by editing the project and target settings. Since revision 274 of the <code>nairn-mpm-fea</code> project, this library must be <tt>xerces 3.0</tt> or newer; prior to that revision, it had be <tt>xerces 2.8</tt> or older. These libraries can be obtained by downloading the
[http://xml.apache.org/xerces-c/index.html | xerces source code] from the [http://www.apache.org/ | Apache Software Foundation] web site and then building and installing <tt>xerces</tt> with the following steps (after seeing potential [[#MacOS X Lion or Newer Command Line Tools|startup issues on Lion or newer systems]]):
 
<ol>
<li>Open Terminal app and navigate to the xerces source folder expanded from the downloaded file.</li>
<li>Configure the code with the command:
<pre>./configure CFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64"</pre>
where the provided <tt>arch</tt> (or architecture) is the desired option for your machine. The main Mac options are <tt>i386</tt> for 32 bit Intel processors, <tt>x86_64</tt> for 64 bit Intel processors,  <tt>ppc</tt> for 32 bit PowerPC chips, or <tt>ppc64</tt> for 64 bit PowerPC64 chips. Although <tt>i386</tt> will work on any Intel processor, you should use <tt>x86_64</tt> if you have a 64 bit processor, because the code will run faster. To determine how many bits your Intel chip has, chose &quot;About This Mac&quot; from the Apple menu, click &quot;More Info...&quot; button, and look up the processor name in the hardware section. The &quot;Intel Core Solo&quot; and &quot;Intel Core Duo&quot; are 32 bit chips and most others are 64 bit chips.</li>
<li>When the configuration is done, use the following commands:
<pre>cd src
make
make install</pre>
These commands make the library (but not the unneeded <tt>xerces</tt> examples). The final install command after <tt>make</tt> is done, installs both the library and the header files at the default locations listed above. If the <tt>make install</tt> shows a permission error, you can solve that by using <tt>sudo make install</tt> instead and provide your administrator password.</li>
<li>When working with <tt>nairn-mpm-fea</tt> on a new Mac, the <tt>xerces</tt> installation only needs to be done once. The only reason to repeat it is when a new <tt>xerces</tt> version is available and/or the project requires a new version for compatibility.</li>
</ol>
 
==== MacOS X Command Line Compiling ====
 
It is easy to compile on MacOS X using a command line approach (after seeing potential <a href="#lion">startup issues on Lion or newer systems</a>). First install <tt>xerces</tt> and its header files as <a href="#xerces">explained above</a> and make sure they are in the specified default locations (if needed).
 
Once the library is ready, you compile <tt>NairnMPM</tt> using:
 
<pre>cd nairn-mpm-fea/NairnMPM/build
make SYSTEM=mac CFLAGS=&quot;-c -O3 -arch x86_64&quot; LFLAGS=&quot;-arch x86_64&quot;
</pre>
 
and compile <tt>NairnFEA</tt> using:
 
<pre>cd nairn-mpm-fea/NairnFEA/build
make SYSTEM=mac CFLAGS=&quot;-c -O3 -arch x86_64&quot; LFLAGS=&quot;-arch x86_64&quot;
</pre>
 
Here the <tt>arch</tt> settings must match the one used when you installed the <tt>xerces</tt> library. The <tt>-c</tt> option is required. The <tt>-O3</tt> option creates optimized code; this option can be changed or omitted.
 
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.
 
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 <a href="#xerces">above</a> 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.
<
 
==== MacOS X Lion or Newer Command Line Tools ====

Latest revision as of 23:14, 21 January 2022

After checking out the nairn-mpm-fea, the next step is to compile it. All code-engine source codes are standard C++ and it should be possible to compile on a variety of systems. This links on this page provide details on some common systems. Users are responsible for compilation on other systems. After this compiling step is completed, you can move on to documentation for running calculations.

Compilation on Various Operating Systems