Difference between revisions of "Compiling"

From BRL-CAD
(Install Dev Tools)
(Update compilation instructions for Git, merge some content from the old Building from SVN page too.)
Line 1: Line 1:
 
= Compiling BRL-CAD =
 
= Compiling BRL-CAD =
  
This page contains simplified steps for building '''''quickly'''''.
+
This page has simplified steps for building '''''quickly'''''.  See [https://github.com/BRL-CAD/brlcad/blob/main/INSTALL INSTALL] for more detailed instruction.
  
== Install Dev Tools ==
 
  
''If you downloaded the virtual machine disk image, skip this step.''
+
== Step 1: Install Dev Tools ==
  
BRL-CAD uses the CMake build system and may be built with most compilers, so first step is to [http://www.cmake.org/cmake/resources/software.html download and install CMake].  If needed, compiling from their source distribution is actually very easy.
+
To build, you need at least [https://cmake.org/download/ CMake] and a compilerYou will also want [https://git-scm.com/downloads/guis Git] to obtain the latest source code.
  
* Debian/Ubuntu: <pre>aptitude install build-essential make cmake</pre>
+
* Windows: Install [https://gitforwindows.org Git], [https://cmake.org/download/ CMake], and [https://visualstudio.microsoft.com/vs/community/ Visual Studio Community].  VS Code should also work.
  
* Fedora: <pre>yum install clang++ make cmake</pre>
+
* Mac: Install [https://cmake.org/download/ CMake] and XCode or run this in Terminal: <pre>xcode-select --install</pre>
  
* CentOS: <pre>yum install python3-pip devtoolset-9 ; pip3 install cmake ; scl enable devtoolset-9 bash</pre>
+
* Linux:
  
== Install Dependencies ==
+
** Debian/Ubuntu: <pre>aptitude install build-essential make cmake</pre>
  
''If you downloaded the virtual machine disk image, skip this step.''
+
** Fedora: <pre>yum install clang++ make cmake</pre>
  
If you're on a Mac or Windows, you're good to go.  For Linux, BSD, and other package-managed systems, you'll want to install a few things.
+
** CentOS: <pre>yum install python3-pip devtoolset-9</pre><pre>pip3 install cmake</pre><pre>scl enable devtoolset-9 bash</pre>
  
* Debian/Ubuntu:
+
* BSD: we assume you know what you're doing and can follow the gist
** <pre>aptitude install sed byacc flex xsltproc</pre>
 
** <pre>aptitude install libncursesw5-dev libfontconfig-dev</pre>
 
** <pre>aptitude install xserver-xorg-dev</pre>
 
** <pre>aptitude install libx11-dev libxi-dev</pre>
 
  
* Fedora: <pre>yum install libx11-devel</pre>
 
  
== Download BRL-CAD ==
+
== Step 2: Install Dependencies ==
  
''If you downloaded the virtual machine disk image, run this to make sure you have the latest sources:''
+
You can skip this step if you're building on Windows or Mac.  Linux and other package-managed systems may need to install a few more things:
<pre>
+
 
svn up brlcad-svn-trunk
+
** Debian/Ubuntu: <pre>aptitude install sed byacc flex xsltproc libncursesw5-dev</pre><pre>aptitude install libfontconfig-dev xserver-xorg-dev libx11-dev libxi-dev<pre>
</pre>
+
 
 +
** Fedora: <pre>yum install libx11-devel</pre>
 +
 
 +
 
 +
== Step 3: Download BRL-CAD ==
 +
 
 +
We recommend obtaining BRL-CAD by forking or cloning our repository on [https://github.com/BRL-CAD/brlcad GitHub].
 +
 
 +
* Windows: Run the Git GUI specifying this as the repository to clone: <pre>https://github.com/BRL-CAD/brlcad.git</pre>
 +
 
 +
* Mac: You can either run the Git GUI, or you can run this in Terminal: <pre>git clone https://github.com/BRL-CAD/brlcad.git</pre>
 +
 
 +
* Linux: <pre>git clone https://github.com/BRL-CAD/brlcad.git</pre>
 +
 
 +
If you run into trouble, snapshot source releases [https://sourceforge.net/projects/brlcad/files/BRL-CAD%20Source/ are available].
 +
 
 +
 
 +
== Step 4: Create a Build directory ==
 +
 
 +
You can create a build folder anywhere, but it's typically named "build" and is in or near your "brlcad" source directory.
 +
 
 +
* Windows: create a folder named "build" inside your "brlcad" folder
 +
 
 +
* Mac, Linux: <pre>mkdir -p brlcad/build</pre>
 +
 
 +
 
 +
== Step 5: Configure ==
 +
 
 +
Next, you'll get ready to compile by running CMake.  For your first time, we recommend setting these CMake variables to avoid trivial errors:
 +
  BRLCAD_ENABLE_STRICT=OFF
 +
  BRLCAD_ENABLE_COMPIELR_WARNINGS=OFF
 +
  BRLCAD_BUNDLED_LIBS=ON
 +
  CMAKE_BUILD_TYPE=Release
  
For everyone else, we recommend obtaining the latest sources from our repository:
+
* Windows: you can use the CMake GUI where you specify your source dir, build dir, and variables.  [[File:Running_cmake_on_windows.png|200px|thumb|right|Running CMake GUI on Windows]]
<pre>
 
svn checkout svn://svn.code.sf.net/p/brlcad/code/brlcad/trunk brlcad-svn-trunk
 
</pre>
 
  
If you run into trouble, snapshot release sources may also be obtained from [https://sourceforge.net/projects/brlcad/files/BRL-CAD%20Source/ Sourceforge].
+
* Mac: You can either run CMake GUI specifying your source dir, build dir, and the above variables, or you can follow the steps for Linux in Terminal.
  
== Configure your Build ==
+
* Linux: <pre>cd brlcad/bulid</pre><pre>cmake .. -DBRLCAD_ENABLE_STRICT=NO -DBRLCAD_BUNDLED_LIBS=ON -DCMAKE_BUILD_TYPE=Release</pre>
  
Next, set up a build directory and configure your compilation:
+
See [https://github.com/BRL-CAD/brlcad/blob/main/INSTALL INSTALL] for more CMake options.
  
<pre>
+
If CMake was successful, there will be a summary of the build printed at the end and it will have generated a build system for compiling BRL-CAD.
cd brlcad-svn-trunk
 
mkdir build
 
cd build
 
cmake .. -DBRLCAD_ENABLE_STRICT=NO -DBRLCAD_BUNDLED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
 
</pre>
 
  
By default, our build enforces code standards that will halt on trivial issues, so we recommend turning off that strict behavior for your first compile.  By default, it will also search your system for dependencies, but this can be complicated so we tell the build to use our bundled versions.  When you graduate to doing development, you'll want to change the build type to -DCMAKE_BUILD_TYPE=Debug instead of Release.
 
  
On a Raspberry Pi running Raspbian 10 also the option -DBRLCAD_ENABLE_COMPILER_WARNINGS=NO is needed for the build to complete.
+
== Step 6: Compile ==
  
BRL-CAD source files contain an [http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/INSTALL INSTALL] file with more detailed instructions if you want to customize the build.
+
Windows: navigate to your build directory and open the BRLCAD.sln file with Visual Studio. Compile the ALL_BUILD solution.
  
== Compile ==
+
Mac, Linux: while still in the build directory from Step 4, run <pre>make</pre>
  
You're good to go, now it's time to compile:
+
If the build fails, re-run while capturing all output to a log: make 2>&1 | tee build.log
<pre>
+
Please [https://github.com/BRL-CAD/brlcad/issues report] any build failures.
make
 
</pre>
 
  
Compilation can 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.
+
Note: Compilation can take anywhere from a couple minutes to an hour depending on hardware.  If you had a quad-core CPU, you might run '"make -j4" to speed things up by compiling in parallel.
  
If the build fails, re-run make while capturing all output to a log: make > build.log 2>&1
 
Please report any build failures.
 
  
== Run! ==
+
== Step 7: Run! ==
  
You don't have to install to run BRL-CAD.  You can just run the binaries you just finished compiling.  They are in the brlcad/.build/bin directory.  There are 400+ tools in BRL-CAD.  Here's a couple to get started:
+
You don't have to install to run BRL-CAD.  You can run the binaries you just compiled as they are in the brlcad/build/bin directory.  There are hundreds of tools in BRL-CAD.  Here's a few to get started:
  
 
<pre>
 
<pre>
Line 82: Line 95:
 
</pre>
 
</pre>
  
The first command will evaluate your system performance.  If you made a Release build, please submit your benchmark results to benchmark at brlcad dot org.
+
The first command (benchmark) will evaluate system performance and you can send results to benchmark at brlcad dot org.
 +
 
 +
The second command (mged) is BRL-CAD's main graphical user interface application.
 +
 
 +
The third command (archer) is BRL-CAD's newer graphical interface under development.
 +
 
  
The second command runs the main graphical interface.  Be sure to check out the extensive [[Documentation]] and [[Main_Page]] for tutorials.
+
= What next? =
  
The third runs our newer graphical interface that is under development.
+
Be sure to check out the [[Documentation|docs]] and [[Main_Page]] for tutorials and more.
  
== What now? ==
+
Help make BRL-CAD better!  There are many ways you can contribute to open source and you don't need to be an experienced programmer.  We need artists, writers, designers, software developers, and managers.  Contact us on [[IRC]].
  
Help make BRL-CAD better!  There are many ways you can contribute to open source and you don't need to be an experienced programmer.  We do need software developers, but we also need artists, writers, designers, and managers.
+
Please [https://github.com/BRL-CAD/brlcad/issues report] any build failures.
  
 
See [[Deuces]] for really easy ways to get started!
 
See [[Deuces]] for really easy ways to get started!

Revision as of 03:34, 8 February 2022

Compiling BRL-CAD

This page has simplified steps for building quickly. See INSTALL for more detailed instruction.


Step 1: Install Dev Tools

To build, you need at least CMake and a compiler. You will also want Git to obtain the latest source code.

  • Mac: Install CMake and XCode or run this in Terminal:
    xcode-select --install
  • Linux:
    • Debian/Ubuntu:
      aptitude install build-essential make cmake
    • Fedora:
      yum install clang++ make cmake
    • CentOS:
      yum install python3-pip devtoolset-9
      pip3 install cmake
      scl enable devtoolset-9 bash
  • BSD: we assume you know what you're doing and can follow the gist


Step 2: Install Dependencies

You can skip this step if you're building on Windows or Mac. Linux and other package-managed systems may need to install a few more things:

    • Debian/Ubuntu:
      aptitude install sed byacc flex xsltproc libncursesw5-dev
      aptitude install libfontconfig-dev xserver-xorg-dev libx11-dev libxi-dev<pre>
    • Fedora: <pre>yum install libx11-devel


Step 3: Download BRL-CAD

We recommend obtaining BRL-CAD by forking or cloning our repository on GitHub.

  • Windows: Run the Git GUI specifying this as the repository to clone:
    https://github.com/BRL-CAD/brlcad.git
  • Mac: You can either run the Git GUI, or you can run this in Terminal:
    git clone https://github.com/BRL-CAD/brlcad.git
  • Linux:
    git clone https://github.com/BRL-CAD/brlcad.git

If you run into trouble, snapshot source releases are available.


Step 4: Create a Build directory

You can create a build folder anywhere, but it's typically named "build" and is in or near your "brlcad" source directory.

  • Windows: create a folder named "build" inside your "brlcad" folder
  • Mac, Linux:
    mkdir -p brlcad/build


Step 5: Configure

Next, you'll get ready to compile by running CMake. For your first time, we recommend setting these CMake variables to avoid trivial errors:

 BRLCAD_ENABLE_STRICT=OFF
 BRLCAD_ENABLE_COMPIELR_WARNINGS=OFF
 BRLCAD_BUNDLED_LIBS=ON
 CMAKE_BUILD_TYPE=Release
  • Windows: you can use the CMake GUI where you specify your source dir, build dir, and variables.
    Running CMake GUI on Windows
  • Mac: You can either run CMake GUI specifying your source dir, build dir, and the above variables, or you can follow the steps for Linux in Terminal.
  • Linux:
    cd brlcad/bulid
    cmake .. -DBRLCAD_ENABLE_STRICT=NO -DBRLCAD_BUNDLED_LIBS=ON -DCMAKE_BUILD_TYPE=Release

See INSTALL for more CMake options.

If CMake was successful, there will be a summary of the build printed at the end and it will have generated a build system for compiling BRL-CAD.


Step 6: Compile

Windows: navigate to your build directory and open the BRLCAD.sln file with Visual Studio. Compile the ALL_BUILD solution.

Mac, Linux: while still in the build directory from Step 4, run

make

If the build fails, re-run while capturing all output to a log: make 2>&1 | tee build.log Please report any build failures.

Note: Compilation can take anywhere from a couple minutes to an hour depending on hardware. If you had a quad-core CPU, you might run '"make -j4" to speed things up by compiling in parallel.


Step 7: Run!

You don't have to install to run BRL-CAD. You can run the binaries you just compiled as they are in the brlcad/build/bin directory. There are hundreds of tools in BRL-CAD. Here's a few to get started:

bin/benchmark run
bin/mged
bin/archer

The first command (benchmark) will evaluate system performance and you can send results to benchmark at brlcad dot org.

The second command (mged) is BRL-CAD's main graphical user interface application.

The third command (archer) is BRL-CAD's newer graphical interface under development.


What next?

Be sure to check out the docs and Main_Page for tutorials and more.

Help make BRL-CAD better! There are many ways you can contribute to open source and you don't need to be an experienced programmer. We need artists, writers, designers, software developers, and managers. Contact us on IRC.

Please report any build failures.

See Deuces for really easy ways to get started!