LibreDWG shared library error

After installation of LibreDWG, Sometimes happens like we are unable to import python module. It gives following error :-

Type "help", "copyright", "credits" or "license" for more information.
>>> import libredwg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/libredwg.py", line 26,
in <module>
    _libredwg = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/libredwg.py", line 22,
in swig_import_helper
    _mod = imp.load_module('_libredwg', fp, pathname, description)
ImportError: libredwg.so.0: cannot open shared object file: No such
file or directory

And if we try to compile examples, at runtime those give error as :-

gcc -g -o testSVG testSVG.c -lredwg -lm
 It gets compiled but when I run it, also gives error as ./testSVG: error while loading shared libraries: libredwg.so.0: cannot open shared object file: No such file or directory

This is basically due to library path problem.
To solve this problem, Open terminal and issue following commands :-

$ ldconfig

this will solve the error.

LibreDWG installation on Linux

GNU LibreDWG is a free C library to handle DWG files. It aims to be a free replacement for the OpenDWG libraries. DWG is the native file format of AutoCAD. GNU LibreDWG is based on LibDWG, originally written by Felipe Castro.

Requirements :-

git, autoconf, gcc, libtool, swig2.0, python-dev, texinfo, build-essential

Installation:-

For debian based distros ( like ubuntu ) :-

$ sudo apt-get install git autoconf libtool swig python-dev texinfo build-essential gcc

#this will check if all dependencies are present other wise will download required ones.

Now clone LibreDWG from Git :-

git clone git://git.sv.gnu.org/libredwg.git

Now change dir to libredwg folder created by git ( cd libredwg ) and issue following commands in terminal :-

$ sh autogen.sh
$ ./configure --enable-trace (this will enable debugging messages)
$ make
$ sudo make install
$ make check

This will install LibreDWG on your system.

Testing:-

LibreDWG comes with several examples (under the examples folder) that can be used for testing purposes. The most advanced example is testSVG.

export LIBREDWG_TRACE=3
cd examples
./testSVG yourdwgfile.dwg > yourconverteddwgfile.svg

This will output a svg format file, containing the dwg data. Note that SVG doesn’t support 3D entities.