Install Open Babel from Source Code on CentOS

Q

How to download and instal Open Babel from source code on CentOS computers? I want to build the binary programs by myself.

✍: FYIcenter.com

A

If you want to build the Open Babel binary programs from source code yourself, you can follow this tutorial.

1. Go to Open Babel Code Repository at https://sourceforge.net/projects/openbabel/.

2. Open "Files > openbabel / 2.4.1" folder. And download openbabel-2.4.1.tar.gz.

3. Unzip and untar the download file. You should see a directory ~/openbabel-2.4.1 with all source code.

4. Create a "build" sub-directory and configure the build system.

fyicenter$ cd openbabel-2.4.1/

fyicenter$ mkdir build 
fyicenter$ cd build 

fyicenter$ cmake .. 
-- The C compiler identification is GNU 8.3.1
-- The CXX compiler identification is GNU 8.3.1
...
-- Checking for module 'cairo'
--   Package 'cairo', required by 'virtual:world', not found
-- Could NOT find Cairo (missing: CAIRO_LIBRARIES CAIRO_INCLUDE_DIRS) 
-- Could NOT find Cairo. PNG output will NOT be supported.
-- Looking for getopt
-- Looking for getopt - found
-- Attempting to build the GUI
--    wxWidgets not found => GUI will not be built
-- Found PythonInterp: /usr/bin/python3.6 (found version "3.6.8") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fyicenter/openbabel-2.4.1/build

5. Run the build process.

fyicenter$ make -j2 
Scanning dependencies of target inchi
Scanning dependencies of target openbabel
[  0%] Building CXX object src/CMakeFiles/openbabel.dir/alias.o
[  0%] Building C object src/formats/libinchi/CMakeFiles/inchi.dir/ichi_bns.o
[  0%] Building C object src/formats/libinchi/CMakeFiles/inchi.dir/ichi_io.o
[  0%] Building C object src/formats/libinchi/CMakeFiles/inchi.dir/ichican2.o
[  1%] Building CXX object src/CMakeFiles/openbabel.dir/atom.o
...
[ 99%] Building CXX object test/CMakeFiles/test_runner.dir/smartstest.o
[ 99%] Building CXX object test/CMakeFiles/test_runner.dir/smartsparse.o
[ 99%] Building CXX object test/CMakeFiles/test_runner.dir/smilesmatch.o
[100%] Building CXX object test/CMakeFiles/test_runner.dir/unitcell.o
[100%] Building CXX object test/CMakeFiles/test_runner.dir/obtest.o
[100%] Linking CXX executable ../bin/test_runner
[100%] Built target test_runner

6. Run tests on the build result. You may see some failures.

fyicenter$ make test 
Running tests...
Test project /home/fyicenter/openbabel-2.4.1/build
        Start   1: test_automorphism_1
  1/151 Test   #1: test_automorphism_1 ..............   Passed    0.01 sec
        Start   2: test_automorphism_2
  2/151 Test   #2: test_automorphism_2 ..............   Passed    0.01 sec
        Start   3: test_automorphism_3
  3/151 Test   #3: test_automorphism_3 ..............   Passed    0.01 sec
        Start   4: test_automorphism_4
        ...
150/151 Test #150: pytest_kekule ....................   Passed    0.32 sec
        Start 151: pytest_pdbformat
151/151 Test #151: pytest_pdbformat .................***Failed    0.03 sec

94% tests passed, 9 tests failed out of 151

Total Test time (real) =  21.85 sec

The following tests FAILED:
   42 - test_gzip_1 (Failed)
   53 - test_isomorphism_5 (Failed)
   54 - test_isomorphism_6 (Failed)
   57 - test_multicml_1 (Failed)
   64 - test_rotor_2 (Failed)
   65 - test_rotor_3 (Failed)
   66 - test_rotor_4 (Failed)
  146 - pytest_sym (Failed)
  151 - pytest_pdbformat (Failed)
Errors while running CTest
make: *** [Makefile:73: test] Error 8

7. Build final installation targets and install them to the default system location.

fyicenter$ sudo make install 
[ 14%] Built target openbabel
[ 16%] Built target plugin_descriptors
[ 20%] Built target plugin_ops
[ 21%] Built target plugin_fingerprints
[ 22%] Built target plugin_forcefields
...
[ 88%] Built target test_inchiwrite
[100%] Built target test_runner
[100%] Built target roundtrip
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/local/include/openbabel-2.0/openbabel/babelconfig.h
-- Installing: /usr/local/lib/pkgconfig/openbabel-2.0.pc
-- Installing: /usr/local/lib/cmake/openbabel2/OpenBabel2_EXPORTS.cmake
-- Installing: /usr/local/lib/cmake/openbabel2/OpenBabel2_EXPORTS-relwithdebinfo.cmake
-- Installing: /usr/local/lib/cmake/openbabel2/OpenBabel2Config.cmake
-- Installing: /usr/local/lib/cmake/openbabel2/OpenBabel2ConfigVersion.cmake
-- Installing: /usr/local/include/inchi/inchi_api.h
...
-- Installing: /usr/local/bin/obthermo
-- Set runtime path of "/usr/local/bin/obthermo" to "/usr/local/lib"
-- Installing: /usr/local/bin/obspectrophore
-- Set runtime path of "/usr/local/bin/obspectrophore" to "/usr/local/lib"
-- Installing: /usr/local/bin/obgrep
-- Set runtime path of "/usr/local/bin/obgrep" to "/usr/local/lib"
-- Installing: /usr/local/bin/roundtrip
-- Set runtime path of "/usr/local/bin/roundtrip" to "/usr/local/lib"

7. Verify installation.

fyicenter$ babel -V
Open Babel 2.4.1 -- May 25 2020 -- 08:24:13

Open Babel command line tools are ready to use.

Note that the building process requires you to have building tools: GCC compiler, CMake, and make.

You can also downlaod Open Babel source code from github.com as https://github.com/openbabel/openbabel

 

Running Open Babel on macOS

Install Open Babel CLI RPM Package for CentOS

Running Open Babel on CentOS

⇑⇑ Open Babel Tutorials

2020-10-10, 171👍, 0💬