lwip 的下载和使用说明

主页

http://savannah.nongnu.org/projects/lwip/

 

下载地址

http://git.savannah.nongnu.org/cgit/lwip.git

 

下载:

git clone git://git.savannah.nongnu.org/lwip.git

 

使用说明 - 【BUILDING 文件内容】

Building lwIP

=============

编译lwip

 

lwIP uses a CMake based build system.

LWIP 使用cmake 编译系统

 

The CMake files in this project are designed to be included into your own CMake files. They are mainly variable definitions containing a list of

source files and predefined static libraries to be linked against application code.

 这个项目中的cmake 应该被你自己项目的cmake文件包含。

这个项目中的cmake文件定义了若干变量,每个变量表示了

一个源文件列表或者一个预定义的静态库。

 

1) lwIP sources:

   src/Filelists.cmake provides file lists containing    the lwIP core library.

   The file also contains two static libraries, lwipcore    and lwipallapps, where you can link your app against.

   This is the file that is useful to all lwIP users.

 src/Filelists.cmake 文件 定义了若干文件列表变量,

提供了两个静态库: lwipcore 和 lwipallapps

可以在你的应用中使用 这些文件列表变量和这两个静态库。

src 文件夹下面的文件通常都会被用到的。

 

2) Example applications:

   contrib/Filelists.cmake provides several file lists    containing the example applications.

   The file also contains several static libraries    for these example apps.    This file is only useful for you, if you can use one

   of the examples in your application, which is normally    not the case.

 

contrib/Filelists.cmake 定义了若干文件列表和若干静态库。

contrib下面的文件不一定能用的上。

 

3) OS/platform port:

   Usually the OS port needs to be provided by the user.    If a port to Linux, Windows or MacOS is useful for

   you, you can use    contrib/ports/{win32, unix}/Filelists.cmake    that contains file lists and libraries for

   these operating systems.

 

平台相关的移植

通常用户需要自己进行移植。

如果移植到 Linux windows 或者 macos的示例对你很有帮助,

你可以使用 contrib/ports/{win32,unix}/Filelists.cmake.

它里面包含了这些平台上面的 若干文件列表变量和若干库

 

VARIABLES

=========

 

In all cases, you need to provide two variables.

【在你include lwip 提供的cmake文件前】

需要提供的变量定义有两个

LWIP_DIR 变量和LWIP_INCLUDE_DIRS

 

"LWIP_DIR" pointing to the lwIP directory

Example:

set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/lwip)

 

LWIP_DIR 变量指示 lwip 源码所在文件夹目录。

示例(假设你将 lwip 源码放置在 externals/lwip 目录下):

set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/lwip)

 

"LWIP_INCLUDE_DIRS" that contains the include base paths

- for lwIP itself (${LWIP_DIR}/src/include)

- for lwIP contrib if you use it (${LWIP_DIR}/contrib)

- to a directory containing an OS port

- to a directory containing lwipopts.h

 

Example:

set (LWIP_INCLUDE_DIRS

    "${LWIP_DIR}/src/include"

    "${LWIP_DIR}/contrib"

    "${LWIP_DIR}/contrib/ports/unix/port/include"

    "${LWIP_DIR}/contrib/examples/example_app"

)

 

LWIP_INCLUDE_DIRS 变量指示了一个 目录列表。

这个目录列表里面需要包含 需要包含4个目录

1、lwip 自身的inlucde 目录

2、【如果你使用到】 lwip contrib 目录

3、一个平台移植文件夹目录

4、一个包含 lwipipts.h 文件的目录

 

 

Putting it all together

=======================

To get a working application, your CMake system needs to provide the variables described above, e.g.

 

将前面所讲组合起来。你的cmake 文件应该是下面这个样子

 

set (LWIP_DIR <path to lwip sources>)

set (LWIP_INCLUDE_DIRS

    "${LWIP_DIR}/src/include"

    "${LWIP_DIR}/contrib"

    "<path to my port>/include"

    "<path to lwipopts.h>"

)

 

# You may add some defines:

set (LWIP_DEFINITIONS LWIP_DEBUG=1)

 

# Then include the filelists you need:

include(${LWIP_DIR}/src/Filelists.cmake)

include(${LWIP_DIR}/contrib/Filelists.cmake)

 

# Then, declare you executable:

add_executable(my_app <my source files> <my lwip port files>)

 

# Add lwIP include dirs to your app:

target_include_directories(my_app PRIVATE ${LWIP_INCLUDE_DIRS})

 

# Link your app against the lwIP libs from the filelists you need:

target_link_libraries(my_app lwipcontribapps lwipallapps lwipcore)

 

Working example

===============

可以工作的cmake 文件示例

 

Working build examples can be found in the

contrib/ports/{win32, unix}/example_app

subdirectory.

 

在 contrib/ports/{win32, unix}/example_app 目录下面。

 

To use them, create a build directory and call cmake with

the lwIP root dir:

 

- mkdir build

- cd build

- cmake ..

- cmake --build .

 

The CMakeLists.txt will autoselect the correct port

for your system (supported: Linux, Windows, Darwin).

 

怎么样使用呢?在lwip 根目录下面建立一个 build文件夹

然后在build 文件夹里面调用cmake

提供的【lwip根目录下面的】CMakeLists.txt 文件会根据你

当前的平台,选择 contrib/ports/{win32 或 unix}/example_app

下面的cmake 文件

posted @ 2022-01-18 22:08  张志伟122  阅读(961)  评论(0编辑  收藏  举报