1.. _vector.oda: 2 3Open Design Alliance - ODA Platform 4=================================== 5 6ODA Platform (previously named Teigha) is required to enable GDAL support for reading AutoCAD DWG and Microstation DGN v8 files. 7GDAL/OGR must be built with ODA support in order to enable these drivers. 8 9ODA required products 10--------------------- 11 12ODA Platform includes several SDK. Drawings SDK provides access to all data in .dwg and .dgn through an object-oriented API. It is required to compile GDAL. 13Since Kernel SDK is required by all products, these two products must be downloaded: 14 15- Kernel 16- Drawings 17 18These libraries are not publicly available. You have to became a member to get access to the libraries. 19Upon authentication the libraries are available from: 20`ODA Member Downloads <https://www.opendesign.com/members/memberfiles>`__ 21 22Get the libraries 23----------------- 24 25To selected the appropriate files to download, consider the following ODA name conventions (for Linux): 26 27- lnx - Linux 28- X86, X64 - indicates X86 or X64 platform 29- 4.4, 4.7, 4.8, 4.9, 5.2, 5.3, 6.3, 7.2, 8.3 - GCC versions 30- dll - indicates a shared library version 31- pic - compiled with Position Independent Code option 32 33ODA archives also contains a release suffix in order to distinguish between releases, like 21.2 or 21.6. 34 35To download the required files for Linux, the following files could be downloaded: 36 37- `Kernel_lnxX64_7.2dll_21.6.tar.gz` 38- `Drawings_lnxX64_7.2dll_21.6.tar.gz` 39 40In this example, the files names are: 41 42- `lnx` for Linux 43- `X64` for X64 architecture 44- `7.2` for gcc 7.2 45- `dll` for shared library version 46- `21.6` ODA 2021 release, build 6 47 48Compiling the libraries 49----------------------- 50 51The libraries must be merged before compiling. 52 53.. code:: bash 54 55 cd ~/dev/cpp/ODA21.6 56 mkdir base_7.2 57 tar xvzf Kernel_lnxX64_7.2dll_21.6.tar.gz -C base_7.2 58 tar xvzf Drawings_lnxX64_7.2dll_21.6.tar.gz -C base_7.2 59 60To compile, an activation key is required. It can be requested from ODA Products Activation. 61The activation key must be copied to `ThirdParty/activation/`. 62 63:: 64 65 cp OdActivationInfo base_7.2/ThirdParty/activation/ 66 67Compile the ODA libraries with: 68 69:: 70 71 cd base_7.2 72 ./configure 73 make -j8 74 75Make sure your gcc major version matches ODA libs gcc version. On Ubuntu, for example, you can install different gcc/g++ versions, like 7, 8 and 9. Switch between them with: 76 77:: 78 79 sudo update-alternatives --config gcc 80 sudo update-alternatives --config g++ 81 82ODA libraries path 83------------------ 84 85After compiling ODA, the resulting libs are in a non standard search path. 86There is no `make install` included to copy the libraries to a standard location. 87This might be an issue. 88 89You have different alternative options to compile and run GDAL/OGR with ODA: 90 91- copy the ODA libraries to a standard location 92- set LD_LIBRARY_PATH (like `LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/jgr/dev/cpp/ODA21.6/base_7.2/bin/lnxX64_7.2dll`). 93- Adding ODA folder to the system library path (`echo "/home/jgr/dev/cpp/ODA21.6/base_7.2/bin/lnxX64_7.2dll" | sudo tee -a /etc/ld.so.conf.d/z_gdal-ODA.conf`) 94- Setting a run time path (`rpath`) when compiling GDAL (like `LDFLAGS="-Wl,-rpath=/home/jgr/dev/cpp/ODA21.6/base_7.2/bin/lnxX64_7.2dll"`). 95 96 97ODA library names 98 99Some ODA library names do not conform the usual Linux standard `lib*.so`. If you don't use `rpath`, for the other alternatives listed above, you might have to create symbolic links from the actual names. Example: 100 101:: 102 103 cd ~/dev/cpp/ODA21.6/base_7.2/bin/lnxX64_7.2dll 104 for f in *.tx 105 do 106 echo "Processing $f" 107 ln -s $f lib$f.so 108 done 109 sudo ldconfig 110 111Check with `ldconfig -v` if all ODA libraries are now visible. 112 113 114Compiling GDAL 115-------------- 116 117After compiling ODA libraries, GDAL can be build using two additional options: 118 119- `--with-teigha=/home/jgr/dev/cpp/ODA21.6/base_7.2` 120- `--with-teigha-plt=lnxX64_7.2dll` 121 122The value of `--with-teigha` is the full path of the folder where the libraries were merged and compiled. 123 124The value of `--with-teigha-plt` must match the platform name used by ODA. The platform name is the folder name under `Platforms`: 125 126:: 127 128 ls -l Platforms/ 129 lnxX64_7.2dll 130 131GDAL compilation 132---------------- 133 134Use your own GDAL build configuration and add the previous mentioned options. After running `configure`, make sure that `Teigha (DWG and DGNv8)` support is configured. 135 136As an example, compiling GDAL can be: 137 138:: 139 140 cd gdal 141 ./autogen.sh 142 ./configure --without-libtool LDFLAGS="-L/usr/lib/x86_64-linux-gnu" --with-python=python3 --with-proj=/usr/local --with-pg=yes --with-poppler --with-teigha=/home/jgr/dev/cpp/ODA21.6/base_7.2 --with-teigha-plt=lnxX64_7.2dll 143 make -j8 144 sudo make install 145 sudo ldconfig 146 # Python support 147 cd swig/python 148 python3 setup.py build 149 sudo python3 setup.py install 150 151We added `LDFLAGS="-L/usr/lib/x86_64-linux-gnu"` to use system libs over ODA's `libpcre`, `libcurl`, etc. 152 153Testing 154------- 155 156After compiling GDAL, you can check if the new drivers `DGNV8` and `DWG` are supported with: 157 158:: 159 160 ./apps/ogrinfo --formats | grep 'AutoCAD\|Microstation' 161 DGN -vector- (rw+v): Microstation DGN 162 DWG -vector- (ro): AutoCAD DWG 163 DGNV8 -vector- (rw+): Microstation DGNv8 164 DXF -vector- (rw+v): AutoCAD DXF 165 CAD -raster,vector- (rovs): AutoCAD Driver 166 167If a file is DGNv8, you will see that driver in action when opening the file: 168 169:: 170 171 ogrinfo ~/dev/cpp/gdal/autotest/ogr/data/dgnv8/test_dgnv8.dgn 172 INFO: Open of `/home/jgr/dev/cpp/gdal/autotest/ogr/data/dgnv8/test_dgnv8.dgn' 173 using driver `DGNV8' successful. 174 1: my_model 175 176Troubleshooting 177--------------- 178 179If you find linking errors, you can set `LD_LIBRARY_PATH` or `LDFLAGS` environment variables to make sure you are able to get the ODA libraries from their location. 180 181Use `ldconfig -v` to check if ODA's library folder is listed. 182 183For example, you can try: 184 185:: 186 187 export LD_LIBRARY_PATH=/home/jgr/dev/cpp/ODA21.6/base_7.2/bin/lnxX64_7.2dll 188 ./configure --without-libtool LDFLAGS="-L/usr/lib/x86_64-linux-gnu" --with-python=python3 --with-proj=/usr/local --with-pg=yes --with-poppler --with-teigha=/home/jgr/dev/cpp/ODA21.6/base_7.2 --with-teigha-plt=lnxX64_7.2dll 189 190You can force a run time location (with `rpath`) with: 191 192:: 193 194 ./configure --without-libtool LDFLAGS="-L/usr/lib/x86_64-linux-gnu -Wl,-rpath=/home/jgr/dev/cpp/ODA21.6/base_7.2/bin/lnxX64_7.2dll" --with-python=python3 --with-proj=/usr/local --with-pg=yes --with-poppler --with-teigha=/home/jgr/dev/cpp/ODA21.6/base_7.2 --with-teigha-plt=lnxX64_7.2dll 195 196 197Adjust these settings, according to your build environment. 198 199See Also 200-------- 201 202- `Introducing the ODA Platform <https://www.opendesign.com/products>`__ 203- :ref:`AutoCAD DWG <vector.dwg>` 204- :ref:`Microstation DGN v8 <vector.dgnv8>` 205