building.rst 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 "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. **CMAKE_BUILD_TYPE**
  61. - RelWithDebInfo: -O2 optimization with debug symbols
  62. - Release: -O2 optimization without debug symbols
  63. - Debug: -O0 optimization with debug symbols
  64. - MinSizeRel: -Os optimization without debug symbols
  65. **UA_LOGLEVEL**
  66. The level of logging events that are reported
  67. - 600: Fatal and all below
  68. - 500: Error and all below
  69. - 400: Error and all below
  70. - 300: Info and all below
  71. - 200: Debug and all below
  72. - 100: Trace and all below
  73. Further options that are not inherited from the CMake configuration are defined
  74. in ua_config.h. Usually there is no need to adjust them.
  75. UA_BUILD_* group
  76. ~~~~~~~~~~~~~~~~
  77. By default only the shared object libopen62541.so or the library open62541.dll
  78. and open62541.dll.a resp. open62541.lib are build. Additional artifacts can be
  79. specified by the following options:
  80. **UA_BUILD_DOCUMENTATION**
  81. Generate documentation with doxygen
  82. **UA_BUILD_EXAMPLECLIENT**
  83. Compile example clients from client.c. There are a static and a dynamic binary client and client_static, respectively
  84. **UA_BUILD_EXAMPLESERVER**
  85. Compile example server from server.c There are a static and a dynamic binary server and server_static, respectively
  86. **UA_BUILD_UNIT_TESTS**
  87. Compile unit tests with Check framework. The tests can be executed with make test
  88. **UA_BUILD_EXAMPLES**
  89. Compile specific examples from https://github.com/acplt/open62541/blob/master/examples/
  90. **UA_BUILD_SELFIGNED_CERTIFICATE**
  91. Generate a self-signed certificate for the server (openSSL required)
  92. UA_ENABLE_* group
  93. ~~~~~~~~~~~~~~~~~
  94. This group contains build options related to the supported OPC UA features.
  95. **UA_ENABLE_SUBSCRIPTIONS**
  96. Enable subscriptions
  97. **UA_ENABLE_METHODCALLS**
  98. Enable method calls in server and client
  99. **UA_ENABLE_NODEMANAGEMENT**
  100. Node management services (adding and removing nodes and references) at runtime in server and client
  101. **UA_ENABLE_AMALGAMATION**
  102. Compile a single-file release files open62541.c and open62541.h
  103. **UA_ENABLE_MULTITHREADING**
  104. Enable multi-threading support (experimental)
  105. **UA_ENABLE_COVERAGE**
  106. Measure the coverage of unit tests
  107. **UA_ENABLE_EMBEDDED_LIBC**
  108. Use a custom implementation of some libc functions that might be missing on embedded targets (e.g. string handling).
  109. Some options are marked as advanced. The advanced options need to be toggled to
  110. be visible in the cmake GUIs.
  111. **UA_ENABLE_EXTERNAL_NAMESPACES**
  112. Enable external namespaces in server
  113. **UA_ENABLE_GENERATE_NAMESPACE0**
  114. Enable automatic generation of NS0
  115. **UA_ENABLE_GENERATE_NAMESPACE0_FILE**
  116. File for NS0 generation from namespace0 folder. Default value is Opc.Ua.NodeSet2.xml
  117. **UA_ENABLE_NONSTANDARD_STATELESS**
  118. Stateless service calls
  119. **UA_ENABLE_NONSTANDARD_UDP**
  120. UDP network layer