[zero] compile separate open62541 source files and header files supporting STM32 platform based on open62541 project

This article was completed around June 2020, but has not been released. The code involved in this article may have changed. Please refer to the official code warehouse

The previous source code download is the same as compiling the source files under Windows, so it will not be repeated

Compiled and generated under Windows c and h file

Software required for windows Platform: cmake, python and visual studio.

The compilation can be carried out in the command line form of cmake or in the form of gui. In order to look good, I will compile with gui.

First select the source directory, then select the compile save directory, and then click Configure and select visual studio to compile and configure. It is OK by default.

Configure according to your needs after completion. Here, I have made the following configuration.

The blue box is required, and then the face cannot be generated c and h separate documents. Then pay attention to the UA below_ freertosLWIP should be selected for architecture, otherwise it will be generated later c and h cannot run on FREERTOS LWIP platform. Then click configure again.

Then you will be asked whether you use freertos' own memory management functions, such as malloc, free, etc. My choice is.

Then click generate to generate the project file of visual studio when there is no problem.

The generation process is fast, but there are hints. Before generating a single file, you can open it with visual studio. You can see many routines in example, such as the following routine that directly generates the official server.

Of course, this is a single open62541 file called, server CPP is generated by calling open62541 C and open62541 H file to establish the server.

However, the single file has not been generated at this time. We need to open the newly compiled directory by opening the project.

After opening, the solution explorer is shown below.

At this point, you can see the header file of the source file of open62541. We can open it and have a look.

You will be prompted that you can't find these two files. This is because we haven't generated them yet, so students who are not clear can have a look first. Next, we will generate separate source files and header files.

In fact, it is also very simple. Right click the solution directly and select generate solution.

You can see that the compilation will report an error, and the figure in front of the file has not changed. We don't need to deal with this error. After that, we can directly open the source file and header file and find that they have been generated.

So far, compiling a separate source file for FREERTOS LWIP platform under Windows has been completed

Compiled and generated under Linux c and h file

Enter the source directory and create the build directory to store the files generated in the compilation process

cd open62541
mkdir build
cd build

Execute cmake to compile, and make will make errors at about 65%, but don't worry, it's normal.

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -DUA_ARCHITECTURE=freertosLWIP -DUA_ENABLE_AMALGAMATION=ON -DUA_ENABLE_PUBSUB=ON DUA_ARCH_FREERTOS_USE_OWN_MEMORY_FUNCTIONS=true -DUA_ARCH_ADD_FLAGS="-std=c99 -DUA_ARCHITECTURE_FREERTOSLWIP -D__REDLIB__ -DDEBUG -D__CODE_RED -D__USE_LPCOPEN -DCORE_M3 -O0 -g3 -Wall -c -fmessage-lengths=0 -fno-buildin -ffunction-section -m3 -mthumb -D__REDLIB__ -fstack-usage -specs=redlib.specs" ../

This is the compilation information of the whole process

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.17") 
-- Found Git: /usr/bin/git (found version "2.17.1") 
-- open62541 Version: 1.1.2-155-gee275e79
-- Architectures included in amalgamation: freertosLWIP
-- The selected architecture is: freertosLWIP
-- Test CC flag -std=c99
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -pipe
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wall
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wextra
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wpedantic
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Werror
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wno-static-in-inline
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wno-overlength-strings
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wno-unused-parameter
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wc++-compat
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wformat
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wformat-security
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wformat-nonliteral
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wmissing-prototypes
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wstrict-prototypes
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wredundant-decls
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wuninitialized
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Winit-self
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wcast-qual
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wstrict-overflow
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wnested-externs
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wmultichar
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -Wundef
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -fno-strict-aliasing
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -fexceptions
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -fstack-protector-strong
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Test CC flag -fstack-clash-protection
-- Performing Test flag_supported
-- Performing Test flag_supported - Failed
-- Test CC flag -mcet
-- Performing Test flag_supported
-- Performing Test flag_supported - Failed
-- Test CC flag -fcf-protection
-- Performing Test flag_supported
-- Performing Test flag_supported - Failed
-- Test CC flag -D_FORTIFY_SOURCE=2
-- Performing Test flag_supported
-- Performing Test flag_supported - Success
-- Could NOT find Sphinx (missing: SPHINX_EXECUTABLE) 
-- Could NOT find LATEX (missing: LATEX_COMPILER) 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xiaohe/github/open62541/build

After execution, the whole compilation process is over. Compared with the setting of graphical interface under Windows, it is much simpler under Linux, and one line of command is done.

Now that the source files of FreeRTOS+Lwip platform have been generated, the next step must be to migrate to stm32

Added by lynncrystal on Tue, 11 Jan 2022 14:24:49 +0200