Menu

Compilation_on_Linux

Anonymous

General Linux

OSRA CLI

  1. Compile and/or install all the necessary [Dependencies].
  2. Unpack OSRA package.
  3. Run ./configure. By default all dependencies should be autodetected. If not, you need to specify them e.g.:

    ./configure --with-tclap-include=/usr/local/include/tclap --with-openbabel-include=/usr/local/include/openbabel-2.0 --with-openbabel-lib=/usr/local/lib
    

    Note: In order to generate and install manpages, you need to --enable-docs
    4. Run make all install. Now you can use OSRA from command-line.

Library support

It is possible to compile OSRA as library (.so).

  1. All prerequisites that are planned to be statically linked, should be compiled with position-independent code enabled (-fPIC) (not relevant for Windows platform). In particular:
    1. For OCRAD: configure; make CXXFLAGS="-fPIC"
    2. For GOCR: configure CFLAGS="-fPIC"; make libs
  2. Run ./configure (add any necessary configuration options):

    ./configure --enable-lib
    
  3. Run make all install. Now both CLI and library are installed.

Java support

  1. Download and unpack Sun JDK.
  2. Make sure that all prerequisites that are planned to be statically linked, are compiled with -fPIC (see previous chapter).
  3. Set the JAVA_HOME variable to point to JDK:

    export JAVA_HOME=/usr/local/jdk1.6.0_27
    
  4. Run ./configure (add any necessary configuration options):

    ./configure --enable-java
    
  5. Run make all install. This will install dictionaries in shared folder and library to libs.

  6. Run mvn install. This will compile Java part of JNI bridge (in target/osra-1.3.6.jar). Alternatively you can use [OsraLib.java](https://osra.svn.sourceforge.net/svnroot/osra/trunk/addons/lib_java_sample/net/sf/osra/OsraLib.java) that does not depend on JNATI library.
  7. Use the source in [OsraLibTest.java](https://osra.svn.sourceforge.net/svnroot/osra/trunk/addons/lib_java_sample/net/sf/osra/OsraLibTest.java) as example of library usage.

Notes:

  • JVM looks up the libraries in system-wide directories but also in specified by java.library.path system property. So when starting the java application, make sure this property is properly setup or OSRA library is in system path (/usr/local/lib is usually not):

    java -Djava.library.path=/usr/local/lib -cp commons-io-1.4.jar net.sf.osra.OsraLibTest
    
  • Under unknown circumstances OpenBabel is not correctly initialized when dynamically loaded by JNI bridge. The symptom is that for any image the JNI version returns empty chemical strcuture while CLI vresion works OK. The solution in this case is the following:

    LD_PRELOAD=/usr/local/lib/libopenbabel.so java ...
    
  • It is nearly not possible to compile library (or java library) statically in Linux. This is because most dependencies (POTRACE / OpenBabel / GraphicsMagick) provide libraries for static linking (.a) without position-independent code enabled (-fPIC). If you wish to include them statically, you need to recompile them the same way as GOCR / OCRAD above (not relevant for Windows platform where all code is position-independent thus creating a statically linked library is easier).

SuSE

OSRA CLI

  • You need SLES v11 or SuSE 11.3.
  • Install the following packages:

    yast -i \
  gcc-c++ libstdc++-devel \
  libGraphicsMagick++2 libGraphicsMagick2 libGraphicsMagick++-devel \
  libopenbabel3 libopenbabel-devel libnetpbm-devel libbz2-devel
    
  • The following packages are needed for --enable-docs:

    yast -i libxslt docbook-xsl-stylesheets
    
  • Download and build tclap (build prerequisites: yast -i doxygen graphviz libtool fdupes):

    # wget -nv 'http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_Factory/src/tclap-1.2.0-6.18.src.rpm'
# rpm -i tclap-1.2.0-6.18.src.rpm
# rpmbuild -ba /usr/src/packages/SPEC/tclap.spec
# rpm -i /usr/src/packages/RPMS/i686/tclap-1.2.0-6.18.i686.rpm
    
  • Download and build potrace (apply the [potrace_1.8.suse.patch.gz](https://sourceforge.net/projects/osra/files/contrib/1.3.6/potrace_1.8.suse.patch.gz/download)or use [potrace-1.8-84.2.src.rpm](https://sourceforge.net/projects/osra/files/contrib/1.3.6/potrace-1.8-84.2.src.rpm/download)):

    # wget -nv 'http://download.opensuse.org/source/distribution/11.2/repo/oss/suse/src/potrace-1.8-84.1.src.rpm'
# rpm -i potrace-1.8-84.1.src.rpm
# zcat potrace_1.8.suse.patch.gz | patch -d /usr/src/packages -p1
# rpmbuild -ba /usr/src/packages/SPECS/potrace.spec
# rpm -i /usr/src/packages/RPMS/i686/{potrace-lib-1.8-84.2.i686.rpm,potrace-devel-1.8-84.2.i686.rpm}
    
  • Download and build ocrad:

    # wget -nv 'https://sourceforge.net/projects/osra/files/contrib/1.3.7/ocrad-0.20-1.0.src.rpm/download'
# rpmbuild --rebuild ocrad-0.20-1.0.src.rpm
# rpm -i /usr/src/packages/RPMS/i686/ocrad-devel-0.20-1.0.i686.rpm
    
  • Download and build gocr

    # wget -nv 'https://sourceforge.net/projects/osra/files/contrib/1.3.7/gocr-0.50-1.0.src.rpm/download'
# rpmbuild --rebuild gocr-0.50-1.0.src.rpm
# rpm -i /usr/src/packages/RPMS/i686/gocr-devel-0.50-1.0.i686.rpm
    
  • Optionally you can download, compile and install Cuneiform and Tesseract (you can use --with-cuneiform --with-tesseract then):

    # wget -nv 'ftp://rpmfind.net/linux/fedora/development/rawhide/source/SRPMS/cuneiform-1.1.0-4.fc17.src.rpm'
# rpmbuild --rebuild cuneiform-1.1.0-4.fc17.src.rpm
# rpm -i /usr/src/packages/RPMS/i686/cuneiform{-devel,}-1.1.0-4.i686.rpm
# wget -nv 'ftp://rpmfind.net/linux/fedora/development/rawhide/source/SRPMS/tesseract-3.00-2.fc15.src.rpm'
# rpmbuild --rebuild tesseract-3.00-2.fc15.src.rpm
# rpm -i /usr/src/packages/RPMS/i686/tesseract{-devel,}-3.00-2.i686.rpm
    
  • Unpack OSRA package and run

    ./configure && make all install
    

L


Related

Wiki: Dependencies