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 文件


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM