building.rst 5.2 KB

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