Difference between revisions of "Compiling"

From BRL-CAD
(Library dependencies)
(update with instructions for the relatively new cmake build system)
Line 1: Line 1:
 
= Compiling BRL-CAD =
 
= Compiling BRL-CAD =
  
BRL-CAD source files contain an INSTALL file with general instructions.  This page contains tips for building on specific systems.
+
BRL-CAD source files contain an [http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/INSTALL INSTALL] file with general instructions.  This page contains simplified tips for building '''''quickly'''''.
  
== Debian / Ubuntu ==
+
== Obtain Dev Tools ==
  
=== Tools ===
+
BRL-CAD uses the CMake build system and will compile with most compilers, so first up is to [http://www.cmake.org/cmake/resources/software.html download and install it].  If needed, compiling from their source distribution is actually very easy.
<pre>
 
aptitude install build-essential libtool
 
</pre>
 
  
=== Library dependencies ===
+
If you're on a Debian/Ubuntu system, you can install pretty much everything you might want with aptitude:
  
 
<pre>
 
<pre>
 +
aptitude install build-essential cmake
 
aptitude install libxi-dev libncursesw5-dev libxt-dev libxslt1-dev libxmu-dev libxmu-headers byacc flex libtnt-dev libxext-dev libpng12-dev zlib1g-dev libsm-dev libx11-dev libxau-dev tk8.5-dev tcl8.5-dev tk8.4-dev tcl8.4-dev itcl3-dev
 
aptitude install libxi-dev libncursesw5-dev libxt-dev libxslt1-dev libxmu-dev libxmu-headers byacc flex libtnt-dev libxext-dev libpng12-dev zlib1g-dev libsm-dev libx11-dev libxau-dev tk8.5-dev tcl8.5-dev tk8.4-dev tcl8.4-dev itcl3-dev
 
</pre>
 
</pre>
  
=== Configure ===
+
== Download BRL-CAD ==
 +
 
 +
Release sources may be obtained from [https://sourceforge.net/projects/brlcad/files/BRL-CAD%20Source/ Sourceforge] or directory from Subversion:
 +
 
 
<pre>
 
<pre>
./configure --enable-optimized
+
svn checkout https://brlcad.svn.sourceforge.net/svnroot/brlcad/brlcad/trunk brlcad
 +
cd brlcad
 
</pre>
 
</pre>
  
=== Make and Install ===
+
== Configure ==
 +
 
 +
Next, we set up a build directory and configure our compilation.  BRL-CAD adhere's to a high conformance standard and considers most warnings as errors, so we turn off that strict behavior just so the build doesn't halt on trivialities.
 +
 
 +
We could add -DCMAKE_BUILD_TYPE=Release to get an optimized build or -DCMAKE_BUILD_TYPE=Debug to get one better suited for development work.
 +
 
 
<pre>
 
<pre>
make
+
mkdir .build
sudo make install
+
cd .build
 +
cmake .. -DBRLCAD_ENABLE_STRICT=OFF
 
</pre>
 
</pre>
  
=== Troubleshooting ===
+
== Compile ==
  
If make returns an error complaining that libitk.la cannot be found, make sure you have libtool installed then do:
+
Compilation will usually take anywhere from a couple minutes to an hour depending on your hardware. If you had a quad-core CPU, you might run '"make -j4" to request compiling in parallel.
  
 
<pre>
 
<pre>
./autogen.sh
 
make noprod
 
 
make
 
make
 +
make test
 
</pre>
 
</pre>
  
If make returns this error:
+
We run make test to see if all went well.  If the build fails, it can be helpful to run make again capturing output to a log file.  E.g., make > build.log 2>&1
  
: ''error: '::ptrdiff_t' has not been declared''
+
== Install ==
  
See Bug Tracker: '''Make error - ID: 2950488'''
+
Depending on the version of sources you start with, BRL-CAD should install into /usr/brlcad/SUBDIR where SUBDIR is rel-VERSION or dev-VERSION.
  
If make returns this error:
+
<pre>
 +
sudo make install
 +
/usr/brlcad/rel-VERSION/bin/mged
 +
</pre>
  
: ''bomb.c:111: error: ignoring return value of ‘write’, declared with attribute warn_unused_result''
+
== Quick test ==
  
See Bug Tracker: '''Error compiling "bomb.c" - ID: 2953632'''
+
You don't have to install, though, and can just run binaries that are in the brlcad/.build/bin directory.
 +
 
 +
<pre>
 +
bin/benchmark
 +
bin/mged
 +
</pre>
  
=== History ===
+
That's it!  If you have a Release compile, you can submit your benchmark results to benchmark at brlcad dot org. Be sure to check out the extensive [[Documentation]] and [[Main_Page]] for tutorials and [[Contributor Quickies]] for ways to get involved!
These tips gleaned from [http://www.linuxquestions.org/questions/linux-software-2/brl-cad-7.14.6-compilation-fails-on-debian-lenny-stable-pentium-6-722382/ knudfl] and [http://ibot.rikers.org/%23brlcad/20080906.html.gz #brlcad].  Tested by JamesVasile on Ubuntu Intrepid with BRL-CAD 7.14.8.
 

Revision as of 11:36, 14 September 2012

Compiling BRL-CAD

BRL-CAD source files contain an INSTALL file with general instructions. This page contains simplified tips for building quickly.

Obtain Dev Tools

BRL-CAD uses the CMake build system and will compile with most compilers, so first up is to download and install it. If needed, compiling from their source distribution is actually very easy.

If you're on a Debian/Ubuntu system, you can install pretty much everything you might want with aptitude:

aptitude install build-essential cmake
aptitude install libxi-dev libncursesw5-dev libxt-dev libxslt1-dev libxmu-dev libxmu-headers byacc flex libtnt-dev libxext-dev libpng12-dev zlib1g-dev libsm-dev libx11-dev libxau-dev tk8.5-dev tcl8.5-dev tk8.4-dev tcl8.4-dev itcl3-dev

Download BRL-CAD

Release sources may be obtained from Sourceforge or directory from Subversion:

svn checkout https://brlcad.svn.sourceforge.net/svnroot/brlcad/brlcad/trunk brlcad
cd brlcad

Configure

Next, we set up a build directory and configure our compilation. BRL-CAD adhere's to a high conformance standard and considers most warnings as errors, so we turn off that strict behavior just so the build doesn't halt on trivialities.

We could add -DCMAKE_BUILD_TYPE=Release to get an optimized build or -DCMAKE_BUILD_TYPE=Debug to get one better suited for development work.

mkdir .build
cd .build
cmake .. -DBRLCAD_ENABLE_STRICT=OFF

Compile

Compilation will usually take anywhere from a couple minutes to an hour depending on your hardware. If you had a quad-core CPU, you might run '"make -j4" to request compiling in parallel.

make
make test

We run make test to see if all went well. If the build fails, it can be helpful to run make again capturing output to a log file. E.g., make > build.log 2>&1

Install

Depending on the version of sources you start with, BRL-CAD should install into /usr/brlcad/SUBDIR where SUBDIR is rel-VERSION or dev-VERSION.

sudo make install
/usr/brlcad/rel-VERSION/bin/mged

Quick test

You don't have to install, though, and can just run binaries that are in the brlcad/.build/bin directory.

bin/benchmark
bin/mged

That's it! If you have a Release compile, you can submit your benchmark results to benchmark at brlcad dot org. Be sure to check out the extensive Documentation and Main_Page for tutorials and Contributor Quickies for ways to get involved!