upm/Documentation/buildingupm.html
2018-11-07 21:32:23 +00:00

2 lines
8.5 KiB
HTML

<!doctype html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><link href="https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700|Roboto:100,300,400,500,700,900" rel="stylesheet"><link rel="shortcut icon" type="image/png" href="/assets/images/favicon.png"/><link rel="stylesheet" href="/assets/css/style.css"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/dracula.min.css"> <script src="/assets/js/library/jquery-2.2.4.min.js"></script> <script src="/assets/js/library/handlebars.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> <script type="text/javascript">hljs.initHighlightingOnLoad();</script> <script type="text/javascript"> $(function(){ var current = location.pathname; $('.nav li a').each(function(){ var $this = $(this); /* if the current path is like this link, make it active */ if($this.attr('href').indexOf(current) !== -1){ $this.addClass('active'); } }) }); </script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-17890616-13', 'auto'); ga('send', 'pageview'); </script><body><header><nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"><div class="container"><div class="row"><div class="col-xs-12 col-sm-5"> <a class="navbar-logo pull-left" href="/"> <img src="/assets/images/logo.png" class="logo-img"> </a><div class="navbar-header pull-right" style="display: inline-block;"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button></div></div><div class="col-sm-7 col-xs-12 menu-inner"><div id="navbar" class="navbar-collapse collapse"><ul class="nav navbar-nav navbar-right nav-list"><li> <a href="/findSensor.html"><span class="icon find-sensor" ></span> <span class="">Find</span></a><li> <a href="/addSensor.html"><span class="icon add-sensor" ></span> <span class="">Join</span></a><li> <a href="/Documentation/docindex.html"><span class="icon documentation" ></span> <span class="">Documentation</span></a><li> <a href="https://github.com/intel-iot-devkit/upm" target="_blank"><span class="icon github github-mobile"></span> <span class="github-desktop">Github</span></a></ul></div></div></div></div></nav></header><main><div class="main-container inner-pages"><div class="container"><div class="row"><div class="col-sm-8 col-xs-12 "><div class="page-heading"> Building UPM</div></div></div></div><div class="section-wrapper installingMraa"><div class="container"><div class="row "><div class="col-xs-12"><div class="sub-title">UPM uses cmake in order to make compilation relatively painless. Cmake runs build out of tree so the recommended way is to clone from git and make a build/ directory.</div><div class="title">Dependencies</div><div class="description"><div> • basic: libmraa, cmake, swig, pkgconfig, pthreads, librt</div><div> • bindings: python-dev, nodejs-dev, openjdk</div><div> • documentation: doxygen, graphviz, sphinx, yuidoc</div><div> • sensor specific: bacnet-mstp, modbus, openzwave, jpeg</div></div></div><div class="col-xs-12"><div class="description"><div class="document-padding">This project depends on libmraa, so that needs to be installed first. Append the install location of mraa pkgconfig to the following environment variable:</div><div><strong>PKG_CONFIG_PATH=$PKG_CONFIG_PATH:.../mraa/build/lib/pkgconfig</strong></div><div class="document-padding">If you are building the Java or Node.js bindings make sure you set the JAVA_HOME and NODE_PATH environment variables respectively.</div><div class="document-padding">UPM will attempt to build all directories inside src/ and they must contain individual CMakeLists.txt files.</div><div><strong> mkdir build<br /> cd build<br /> cmake .. <br /> make<br /> make install </strong></div><div class="document-padding">The last command will create the include/ and lib/ directories with a copy of the headers and library objects respectively in your build location. Note that doing an out-of-source build may cause issues when rebuilding later on.</div><div class="description document-padding">Our cmake configure has a number of options, cmake-gui or ccmake can show you all the options. The interesting ones are detailed below:</div><div class="title">Changing install path from /usr/local to /usr</div><div class="description">-DCMAKE_INSTALL_PREFIX:PATH=/usr</div><div class="title">Building debug build:</div><div class="description">-DCMAKE_BUILD_TYPE=DEBUG</div><div class="title">Using clang instead of gcc:</div><div class="description">-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++</div><div class="title">Cross-compiling on a different system:</div><div class="description"><div>-DCMAKE_CXX_FLAGS:STRING=-m32 -march=i586</div><div>-DCMAKE_C_FLAGS:STRING=-m32 -march=i586</div></div><div class="title">Enabling Java module building</div><div class="description">-DBUILDSWIGJAVA=ON</div><div class="title">Building with an older version of swig (swig 2.0+) requires the disabling of javascript:</div><div class="description">--DBUILDSWIGNODE=OFF</div><div class="title">Generating python3 modules instead of python2.7</div><div class="description">-DBUILDPYTHON3=ON</div><div class="title">Disabling python module building</div><div class="description">-DBUILDSWIGPYTHON=OFF</div><div class="title">Setting the python library to use:</div><div class="description">--DPYTHON_LIBRARY:FILEPATH=/usr/lib/libpython2.7.so.1.0</div><div class="title">Building documentation</div><div class="description">-DBUILDDOC=ON</div><div class="title">Build C/C++/JAVA examples</div><div class="description">-DBUILDEXAMPLES=ON</div><div class="document-padding">If you intend to turn on all the options and build everything at once (C++, Java, Node, Python and Documentation) you will have to edit the src/doxy2swig.py file and change the line endings from Windows style to Linux format. This has to be repeated every time to sync with the master branch since our Github repository stores files using CR LF line breaks.</div><div class="document-padding">You can also generate the include and lib directories containing all the sensor headers and library files respectively with make install. Further, you may choose to generate these only for a specific sensor you modified, and this can be achieved by building from the individual makefile of the sensor. Assuming you're in the build directory, to make the lcd module you would:</div><div> <strong> cd src/lcd<br /> make install </strong></div><div class="document-padding">Often developers are only interested in building one module or even just the python/node module to do some quick testing using scripting. In order to do this you need to use the target name for the python or node module you want to rebuild. For example the lcd module target name is i2clcd. Therefore the python module target name will be prefixed by pyupm. Just do the following to build only that module. Modules not using the UPM cmake macros may have different naming.</div><div> <strong> make _pyupm_i2clcd </strong></div><div class="document-padding"> Sometimes you want to build a small C++ example against an installed library. This is fairly easy if installed system-wide. Just link against the correct library (in this case libupm-i2clcd) and then add /usr/include/upm to the loader path:</div><div class="document-padding"> <strong> g++ test.cxx -lupm-i2clcd -I/usr/include/upm </strong></div><div class="document-padding">You can also use pkg-config to return the information to you, which is considered the correct way if including UPM in a build system like cmake or autotools on linux.</div><div> <strong> pkg-config --cflags --libs upm-i2clcd </strong></div><br /></div></div></div></div></div></div><footer class="site-footer"><div class="container"><div class="row"><div class="col-xs-6"><p class="text-muted">(* Trademarks)</div><div class="col-xs-6 text-right"><p class="text-muted">&copy; 2017 UPM</div></div></div><script src="/assets/js/library/bootstrap.min.js"></script></footer></main>