Skip to content

k-ujihara/build-rdkit

Repository files navigation

RDKit for .NET Framework

How to Build

Build Instruction

Do the following procedure.

  • Build native binaries for Windows
  • Build native binaries for Linux
  • Build .NET wrapper
  • Build NuGet package

Build native binaries for Windows 10 (x64)

  • On Windows 10 (x64)
  • Install Visual Studio 2019 enabling C++, C# and CMAKE.
  • Install Python version greater than 3.8.
  • Install SWIG.
    • IMPORTANT: SWIG-3.0 is required. SWIG-4.0 does not work.
  • Make sure Python and SWIG are executable.
  • Clone this repository to some directory. A name of the directory including path should be short. It is highly recommended to place it under 'C:'.
  • Download the following source archives and extract them here.
  • Download binery archives of both 32-bit and 64-bit versions of Boost for Visual Studio 2019, ie, msvc-14.2.
    • https://sourceforge.net/projects/boost/files/boost-binaries/.
    • Execute EXE files to extract. Defaults to store to C:\local.
    • Copy boost_#_##_# directory here.
    • Only dll and lib, ie, the files in lib64-msvc-14.# and lib32-msvc-14.#, are used to build.
    • After above, lib64-msvc-14.# and lib32-msvc-14.# should be created under boost_#_##_# directory.
  • Customize config.txt file according to where above dependencies are installed.
  • Open Developer Command Prompt for VS 2019.
  • Execute bash build_win.bat to create native binaries in ${RDKIT_DIR}/Code/JavaWrappers/csharp_wrapper/win/.

Build native binaries for Ubuntu 18.4

  • Don't share with Windows build.
  • Ubuntu 18.4 is recommended.
  • Install python 3.8 or greater, swig 3.0, and eigen3.
  • Install dotnet-sdk-5.0 and Mono.
sudo wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
    sudo dpkg -i packages-microsoft-prod.deb && \
    sudo rm packages-microsoft-prod.deb && \
    sudo apt-get update && \
    sudo apt-get install -y apt-transport-https && \
    sudo apt-get update && \
    sudo apt-get install -y dotnet-sdk-5.0 && \
    sudo apt-get install -y mono-mcs
  • Clone this repository.
  • Download the following source archives and extract them here.
    • RDKit to rdkit-Release_####_##_#.
  • Customize config.txt file according to where above dependencies are installed.
  • Execute bash build_linux.sh to create native binaries in ${RDKIT_DIR}/Code/JavaWrappers/csharp_wrapper/linux/.

Build .NET wrapper

  • On Windows 10 (x64)
  • Open Developer Command Prompt for VS 2019.
  • Execute python ./build_rdkit_csharp.py --build_wrapper to create assembry files named RDKit2DotNet.dll in ${RDKIT_DIR}\Code\JavaWrappers\csharp_wrapper\RDKit2DotNet\bin\Release\.

Build and create NuGet package

  • Open Developer Command Prompt for VS 2019.
  • Copy native binaries for Linux to ${RDKIT_DIR}/Code/JavaWrappers/csharp_wrapper/linux/.
  • Execute python ./build_rdkit_csharp.py --build_nuget to create NuGet package on ${RDKIT_DIR}\Code\JavaWrappers\csharp_wrapper\RDKit2DotNet\bin\Release\.

Copy created NuGet package to myApp

  • Open Developer Command Prompt for VS 2019.
  • Execute nmake -f Makefile.win copy_to_myapp.

Install SWIG-3.0.12

Because RDKit's CMakeFile.txt does not work with SWIG 4.0, we need to install SWIG-3.0.

for Windows

Download SWIG executable from https://sourceforge.net/projects/swig/files/swigwin/swigwin-3.0.12/, extract, and add the directory to PATH.

for Linux

If SWIG-3.0 package is not availabe in your system, install it from source with the following instruction.

sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
wget https://sourceforge.net/projects/swig/files/swig/swig-3.0.12/swig-3.0.12.tar.gz
tar -zxvf swig-3.0.12.tar.gz
cd swig-3.0.12
./configure
make
sudo make install
make clean

If you required to uninstall SWIG-4.0, do the following.

sudo apt-get --purge remove swig

Build Java wrapper

Do below to build and run test.

make -f Makefile.linux rdkit_java_test USE_BOOST=TRUE
cd ${RDKIT_DIR}/Code/JavaWrappers/gmwrapper/
wget https://repo1.maven.org/maven2/junit/junit/4.13/junit-4.13.jar
mv junit-4.13.jar junit4.jar
wget https://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
mv remotecontent\?filepath=org%2Fhamcrest%2Fhamcrest-core%2F1.3%2Fhamcrest-core-1.3.jar hamcrest-core.jar
export RDBASE=${RDKIT_DIR}
LD_LIBRARY_PATH=${RDKIT_DIR}/Code/JavaWrappers/gmwrapper:$LD_LIBRARY_PATH java -cp ${RDKIT_DIR}/Code/JavaWrappers/gmwrapper/junit4.jar:${RDKIT_DIR}/Code/JavaWrappers/gmwrapper/hamcrest-core.jar:${RDKIT_DIR}/Code/JavaWrappers/gmwrapper/org.RDKit.jar:${RDKIT_DIR}/Code/JavaWrappers/gmwrapper/build-test org.junit.runner.JUnitCore org.RDKit.GraphMolTestSuite