building.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. .. _building:
  2. Building open62541
  3. ==================
  4. Building the Examples
  5. ---------------------
  6. Using the GCC compiler, the following calls build the examples on Linux.
  7. .. code-block:: bash
  8. cp /path-to/open62541.* . # copy single-file distribution to the local directory
  9. cp /path-to/examples/server_variable.c . # copy the example server
  10. gcc -std=c99 open62541.c server_variable.c -o server
  11. Building the Library
  12. --------------------
  13. Building with CMake on Ubuntu or Debian
  14. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  15. .. code-block:: bash
  16. sudo apt-get install git build-essential gcc pkg-config cmake python
  17. # enable additional features
  18. sudo apt-get install liburcu-dev # for multithreading
  19. sudo apt-get install check # for unit tests
  20. sudo apt-get install sphinx graphviz # for documentation generation
  21. sudo apt-get install python-sphinx-rtd-theme # documentation style
  22. cd open62541
  23. mkdir build
  24. cd build
  25. cmake ..
  26. make
  27. # select additional features
  28. ccmake ..
  29. make
  30. Building with CMake on Windows
  31. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  32. Here we explain the build process for Visual Studio (2013 or newer). To build
  33. with MinGW, just replace the compiler selection in the call to CMake.
  34. - Download and install
  35. - Python 2.7.x (Python 3.x should work, too): https://python.org/downloads
  36. - CMake: http://www.cmake.org/cmake/resources/software.html
  37. - Microsoft Visual Studio 2015 Community Edition: https://www.visualstudio.com/products/visual-studio-community-vs
  38. - Download the open62541 sources (using git or as a zipfile from github)
  39. - Open a command shell (cmd) and run
  40. .. code-block:: bat
  41. cd <path-to>\open62541
  42. mkdir build
  43. cd build
  44. <path-to>\cmake.exe .. -G "Visual Studio 14 2015"
  45. :: You can use use cmake-gui for a graphical user-interface to select features
  46. - Then open :file:`build\open62541.sln` in Visual Studio 2015 and build as usual
  47. Building on OS X
  48. ^^^^^^^^^^^^^^^^
  49. - Download and install
  50. - Xcode: https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12
  51. - Homebrew: http://brew.sh/
  52. - Pip (a package manager for python, may be preinstalled): ``sudo easy_install pip``
  53. - Run the following in a shell
  54. .. code-block:: bash
  55. brew install cmake
  56. pip install sphinx # for documentation generation
  57. pip install sphinx_rtd_theme # documentation style
  58. brew install graphviz # for graphics in the documentation
  59. brew install check # for unit tests
  60. brew install userspace-rcu # for multi-threading support
  61. Follow Ubuntu instructions without the ``apt-get`` commands as these are taken care of by the above packages.
  62. Building on OpenBSD
  63. ^^^^^^^^^^^^^^^^^^^
  64. The procedure below works on OpenBSD 5.8 with gcc version 4.8.4, cmake version 3.2.3 and Python version 2.7.10.
  65. - Install a recent gcc, python and cmake:
  66. .. code-block:: bash
  67. pkg_add gcc python cmake
  68. - Tell the system to actually use the recent gcc (it gets installed as egcc on OpenBSD):
  69. .. code-block:: bash
  70. export CC=egcc CXX=eg++
  71. - Now procede as described for Ubuntu/Debian:
  72. .. code-block:: bash
  73. cd open62541
  74. mkdir build
  75. cd build
  76. cmake ..
  77. make
  78. Build Options
  79. -------------
  80. Build Type and Logging
  81. ^^^^^^^^^^^^^^^^^^^^^^
  82. **CMAKE_BUILD_TYPE**
  83. - ``RelWithDebInfo`` -O2 optimization with debug symbols
  84. - ``Release`` -O2 optimization without debug symbols
  85. - ``Debug`` -O0 optimization with debug symbols
  86. - ``MinSizeRel`` -Os optimization without debug symbols
  87. **UA_LOGLEVEL**
  88. The level of logging events that are reported
  89. - 600: Fatal and all below
  90. - 500: Error and all below
  91. - 400: Error and all below
  92. - 300: Info and all below
  93. - 200: Debug and all below
  94. - 100: Trace and all below
  95. Further options that are not inherited from the CMake configuration are defined
  96. in :file:`ua_config.h`. Usually there is no need to adjust them.
  97. UA_BUILD_* group
  98. ^^^^^^^^^^^^^^^^
  99. By default only the shared object libopen62541.so or the library open62541.dll
  100. and open62541.dll.a resp. open62541.lib are build. Additional artifacts can be
  101. specified by the following options:
  102. **UA_BUILD_DOCUMENTATION**
  103. Generate Make targets for documentation
  104. * HTML documentation: ``make doc``
  105. * Latex Files: ``latex``
  106. * PDF documentation: ``make pdf``
  107. **UA_BUILD_EXAMPLES**
  108. Compile example servers and clients from :file:`examples/{xyz}.c`. A static and a dynamic binary is linked, respectively.
  109. **UA_BUILD_UNIT_TESTS**
  110. Compile unit tests with Check framework. The tests can be executed with ``make test``
  111. **UA_BUILD_EXAMPLES_NODESET_COMPILER**
  112. Generate an OPC UA information model from a nodeset XML (experimental)
  113. **UA_BUILD_SELFIGNED_CERTIFICATE**
  114. Generate a self-signed certificate for the server (openSSL required)
  115. UA_ENABLE_* group
  116. ^^^^^^^^^^^^^^^^^
  117. This group contains build options related to the supported OPC UA features.
  118. **UA_ENABLE_SUBSCRIPTIONS**
  119. Enable subscriptions
  120. **UA_ENABLE_METHODCALLS**
  121. Enable the Method service set
  122. **UA_ENABLE_NODEMANAGEMENT**
  123. Enable dynamic addition and removal of nodes at runtime
  124. **UA_ENABLE_AMALGAMATION**
  125. Compile a single-file release files :file:`open62541.c` and :file:`open62541.h`
  126. **UA_ENABLE_MULTITHREADING**
  127. Enable multi-threading support
  128. **UA_ENABLE_COVERAGE**
  129. Measure the coverage of unit tests
  130. Some options are marked as advanced. The advanced options need to be toggled to
  131. be visible in the cmake GUIs.
  132. **UA_ENABLE_TYPENAMES**
  133. Add the type and member names to the UA_DataType structure
  134. **UA_ENABLE_GENERATE_NAMESPACE0**
  135. Generate and load UA XML Namespace 0 definition
  136. ``UA_GENERATE_NAMESPACE0_FILE`` is used to specify the file for NS0 generation from namespace0 folder. Default value is ``Opc.Ua.NodeSet2.xml``
  137. **UA_ENABLE_EMBEDDED_LIBC**
  138. Use a custom implementation of some libc functions that might be missing on embedded targets (e.g. string handling).
  139. **UA_ENABLE_EXTERNAL_NAMESPACES**
  140. Enable namespace handling by an external component (experimental)
  141. **UA_ENABLE_NONSTANDARD_STATELESS**
  142. Enable stateless extension
  143. **UA_ENABLE_NONSTANDARD_UDP**
  144. Enable udp extension
  145. Building a shared library
  146. ^^^^^^^^^^^^^^^^^^^^^^^^^
  147. open62541 is small enough that most users will want to statically link the library into their programs. If a shared library (.dll, .so) is required, this can be enabled in CMake with the `BUILD_SHARED_LIBS` option.
  148. Note that this option modifies the :file:`ua_config.h` file that is also included in :file:`open62541.h` for the single-file distribution.