From 0f1c83c948abf141b6f46a8d2ba155c427e31e57 Mon Sep 17 00:00:00 2001 From: Ric Li Date: Fri, 19 May 2023 13:33:40 +0800 Subject: [PATCH] Win: add MSVC sample code and build guide (#278) Signed-off-by: Ric Li --- README.md | 2 +- app/sample/msvc/README.md | 39 +++ app/sample/msvc/imtl_sample/imtl_sample.cpp | 135 ++++++++ app/sample/msvc/imtl_sample/imtl_sample.sln | 31 ++ .../msvc/imtl_sample/imtl_sample.vcxproj | 144 +++++++++ .../imtl_sample/imtl_sample.vcxproj.filters | 22 ++ .../msvc/imtl_sample/imtl_sample.vcxproj.user | 4 + doc/build_WIN.md | 300 +++++------------- doc/build_WIN_MSYS2.md | 134 -------- doc/run_WIN.md | 89 +++--- doc/vm_WIN.md | 2 +- lib/meson.build | 2 + 12 files changed, 508 insertions(+), 396 deletions(-) create mode 100644 app/sample/msvc/README.md create mode 100644 app/sample/msvc/imtl_sample/imtl_sample.cpp create mode 100644 app/sample/msvc/imtl_sample/imtl_sample.sln create mode 100644 app/sample/msvc/imtl_sample/imtl_sample.vcxproj create mode 100644 app/sample/msvc/imtl_sample/imtl_sample.vcxproj.filters create mode 100644 app/sample/msvc/imtl_sample/imtl_sample.vcxproj.user delete mode 100644 doc/build_WIN_MSYS2.md diff --git a/README.md b/README.md index f4127fdb..19083154 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ The library also includes SIMD CSC (color space format conversion), DMA, and plu Please refer to [build guide](doc/build.md) for instructions on how to build DPDK, the library, and the sample application. -For Windows, please refer to the [Win build guide](doc/build_WIN_MSYS2.md) or instructions on how to build. +For Windows, please refer to the [Win build guide](doc/build_WIN.md) for instructions on how to build. ## 3. Run ST2110 diff --git a/app/sample/msvc/README.md b/app/sample/msvc/README.md new file mode 100644 index 00000000..bc434dcf --- /dev/null +++ b/app/sample/msvc/README.md @@ -0,0 +1,39 @@ +# Sample code for how to develop application in MSVC + +## 1. Introduction + +The is sample code for how to develop MSVC application quickly based on Intel® Media Transport Library. The guide is verified with Visual Studio 2022 (v143). + +## 2. Steps + +### 2.1 Prepare latest .lib file + +* Build IMTL library in MSYS2, see [WIN build guide](../../../doc/build_WIN.md), also need to add MSYS2 binary PATH to system environment variables. + +* After build, in the build folder, you will get `libmtl.def` file. + +* Open Developer Command Prompt for VS here, run below command: + + ```powershell + lib /machine:x64 /def:libmtl.def + ``` + +* Copy `libmtl.lib` to project folder. + +### 2.2 Set project properties + +* Double-click `imtl_sample.sln` to launch VS or create a console app in VS with the `imtl_sample.cpp`. + +* In Solution Explorer, right click on project, open Properties window, choose the configuration needed, such as `Release - x64`. + +* Go to VC++ Directories, add MSYS2 Environment include folder(eg. for UCRT64, `C:\msys64\ucrt64\include`) to `External Include Directories`. + +* Go to Linker - Input, add `libmtl.lib` to `Additional Dependencies` + +* Click `OK` or `Apply` to save properties. + +### 2.3 Build and run + +* Inside IDE: Click Run button (Local Windows Debugger/ Start Without Debugging) to build and run the application. + +* Run binary: After build, go to output folder(eg. x64\Release), double-click `imtl_sample.exe` to run. diff --git a/app/sample/msvc/imtl_sample/imtl_sample.cpp b/app/sample/msvc/imtl_sample/imtl_sample.cpp new file mode 100644 index 00000000..a4d675fd --- /dev/null +++ b/app/sample/msvc/imtl_sample/imtl_sample.cpp @@ -0,0 +1,135 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Intel Corporation + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +static std::mutex mtx; +static std::condition_variable cv; +static uint32_t fb_done = 0; +static bool stop = false; +static mtl_handle g_st = NULL; + +void signalHandler(int signum) { + std::cout << "SIGINT received - exiting!\n"; + switch (signum) { + case SIGINT: + stop = true; + if (g_st != NULL) mtl_abort(g_st); + break; + } +} + +int main() { + int ret = 0; + std::cout << "Starting IMTL sample..." << std::endl << mtl_version() << std::endl; + + std::signal(SIGINT, signalHandler); + + /* setting of parameters */ + struct mtl_init_params param; + memset(¶m, 0, sizeof(param)); + strncpy_s(param.port[MTL_PORT_P], "0000:03:00.0", MTL_PORT_MAX_LEN); + param.num_ports = 1; + param.sip_addr[MTL_PORT_P][0] = 192; + param.sip_addr[MTL_PORT_P][1] = 168; + param.sip_addr[MTL_PORT_P][2] = 96; + param.sip_addr[MTL_PORT_P][3] = 12; + param.log_level = MTL_LOG_LEVEL_INFO; + param.tx_sessions_cnt_max = 1; + param.rx_sessions_cnt_max = 0; + + /* init mtl */ + mtl_handle st = mtl_init(¶m); + if (st == NULL) { + std::cout << "mtl_init fail" << std::endl; + return -EIO; + } + g_st = st; + + /* create a st2110-20 pipeline tx session */ + struct st20p_tx_ops ops_tx; + memset(&ops_tx, 0, sizeof(ops_tx)); + ops_tx.name = "st20p_tx_sample"; + ops_tx.port.num_port = 1; + uint8_t dip[4] = {239, 19, 96, 1}; + memcpy(ops_tx.port.dip_addr[MTL_SESSION_PORT_P], dip, MTL_IP_ADDR_LEN); + strncpy_s(ops_tx.port.port[MTL_SESSION_PORT_P], param.port[MTL_PORT_P], + MTL_PORT_MAX_LEN); + ops_tx.port.udp_port[MTL_SESSION_PORT_P] = 20000; + ops_tx.port.payload_type = 112; + ops_tx.width = 1920; + ops_tx.height = 1080; + ops_tx.fps = ST_FPS_P59_94; + ops_tx.input_fmt = ST_FRAME_FMT_YUV422RFC4175PG2BE10; + ops_tx.transport_fmt = ST20_FMT_YUV_422_10BIT; + ops_tx.device = ST_PLUGIN_DEVICE_AUTO; + ops_tx.framebuff_cnt = 3; + auto sample_frame_available = [](void* priv) { + cv.notify_one(); + return 0; + }; + auto sample_frame_done = [](void* priv, struct st_frame* frame) { + fb_done++; + return 0; + }; + ops_tx.notify_frame_available = sample_frame_available; + ops_tx.notify_frame_done = sample_frame_done; + + st20p_tx_handle tx_handle = st20p_tx_create(st, &ops_tx); + if (tx_handle == NULL) { + mtl_uninit(st); + return -EIO; + } + + auto sample_frame_thread = [tx_handle]() { + struct st_frame* frame; + while (!stop) { + frame = st20p_tx_get_frame(tx_handle); + if (!frame) { /* no frame */ + { + std::unique_lock lock(mtx); + cv.wait(lock); + } + continue; + } + + // do something to frame + + st20p_tx_put_frame(tx_handle, frame); + } + }; + + std::thread frame_thread(sample_frame_thread); + + ret = mtl_start(st); + + while (!stop) { + Sleep(1000); + } + + cv.notify_one(); + frame_thread.join(); + if (tx_handle) st20p_tx_free(tx_handle); + + ret = mtl_stop(st); + + /* uninit mtl */ + if (st != NULL) { + mtl_uninit(st); + st = NULL; + } + + std::cout << "Stopped, fb_done: " << fb_done << std::endl; + + return ret; +} diff --git a/app/sample/msvc/imtl_sample/imtl_sample.sln b/app/sample/msvc/imtl_sample/imtl_sample.sln new file mode 100644 index 00000000..cfaa8aac --- /dev/null +++ b/app/sample/msvc/imtl_sample/imtl_sample.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33627.172 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imtl_sample", "imtl_sample.vcxproj", "{CBC62708-F271-4168-9F29-5FA5C061F541}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CBC62708-F271-4168-9F29-5FA5C061F541}.Debug|x64.ActiveCfg = Debug|x64 + {CBC62708-F271-4168-9F29-5FA5C061F541}.Debug|x64.Build.0 = Debug|x64 + {CBC62708-F271-4168-9F29-5FA5C061F541}.Debug|x86.ActiveCfg = Debug|Win32 + {CBC62708-F271-4168-9F29-5FA5C061F541}.Debug|x86.Build.0 = Debug|Win32 + {CBC62708-F271-4168-9F29-5FA5C061F541}.Release|x64.ActiveCfg = Release|x64 + {CBC62708-F271-4168-9F29-5FA5C061F541}.Release|x64.Build.0 = Release|x64 + {CBC62708-F271-4168-9F29-5FA5C061F541}.Release|x86.ActiveCfg = Release|Win32 + {CBC62708-F271-4168-9F29-5FA5C061F541}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {12481933-37E5-4B00-B0F6-974E7A13CF83} + EndGlobalSection +EndGlobal diff --git a/app/sample/msvc/imtl_sample/imtl_sample.vcxproj b/app/sample/msvc/imtl_sample/imtl_sample.vcxproj new file mode 100644 index 00000000..99f0f57b --- /dev/null +++ b/app/sample/msvc/imtl_sample/imtl_sample.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {cbc62708-f271-4168-9f29-5fa5c061f541} + imtlsample + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + C:\msys64\ucrt64\include;$(ExternalIncludePath) + $(LibraryPath) + + + C:\msys64\ucrt64\include;$(ExternalIncludePath) + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + libmtl.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + libmtl.lib;%(AdditionalDependencies) + + + + + + + + + \ No newline at end of file diff --git a/app/sample/msvc/imtl_sample/imtl_sample.vcxproj.filters b/app/sample/msvc/imtl_sample/imtl_sample.vcxproj.filters new file mode 100644 index 00000000..8c71ed4e --- /dev/null +++ b/app/sample/msvc/imtl_sample/imtl_sample.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/app/sample/msvc/imtl_sample/imtl_sample.vcxproj.user b/app/sample/msvc/imtl_sample/imtl_sample.vcxproj.user new file mode 100644 index 00000000..88a55094 --- /dev/null +++ b/app/sample/msvc/imtl_sample/imtl_sample.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/doc/build_WIN.md b/doc/build_WIN.md index 357f5014..234c1eac 100644 --- a/doc/build_WIN.md +++ b/doc/build_WIN.md @@ -1,280 +1,134 @@ -# Intel® Media Transport Library compilation and build on Windows OS +# Intel® Media Transport Library compilation and build on Windows OS (MSYS2) ## 1. Introduction -> Update: for quick installation with package management tools in MSYS2 environment, please see [build_WIN_MSYS2.md](build_WIN_MSYS2.md) +This document contains instructions for installing and configuring the Intel® Media Transport Library for Windows Operation System in MSYS2 environment. -This document contains instructions for installing and configuring the Intel® Media Transport Library for Windows Operation System. +## 2. Prerequisites -All the steps below related to the DPDK configuration instructions on Windows are from the website: - +* Windows 10 / Windows Server 2019 64-bit or higher -### 1.1 OS +## 3. Install MSYS2 environment -- Tested on: Windows Server 2022 - -## 2. Preparation of the environment - -To prepare the environment, follow the instructions on the DPDk windows page. -The recommended options is: -"MinGW-w64 Toolchain" - -### 2.1 PATH environmental variable in Windows - -After downloading and installing Meson and Ninja you must add them to the PATH environmental variable in Windows. -Search for edit the system environment variables and run the program. -Click on Environment Variables... button and then in the upper section click on Path variable and click edit. -Then add it to your environment variable by clicking new and writing the path down to them just like in the example below. - -meson version 0.57.0 is recommended version - -for example: +* Download and install MSYS2 from . +* Open an MSYS2 MINGW64/UCRT64 shell, all commands in this doc will be run in this shell. +* Update packages: ```bash -C:\Program Files\Meson -C:\Ninja +pacman -Syu ``` -## 3. Installation and configuration of DPDK - -First install compile tools mingw64, suggest to install to c:\mingw64 - - -### 3.1 Preparation of sources - -#### 3.1.1 Download DPDK sources from - - +## 4. Install dependencies -#### 3.1.2 Unpack the sources - -To unpack you can use 7-zip: - -• Right-click the file - -• Select 7-zip -> Extract Here / Extract to - -#### 3.1.3 Patch dpdk-22.11 with custom patches - -Install git for Windows version -Run the following commands using gitbash: -Execute below command in Git bash +* Install build tools and dependencies: ```bash -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0001-pcapng-add-ns-timestamp-for-copy-api.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0002-net-af_xdp-parse-numa-node-id-from-sysfs.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0003-net-iavf-refine-queue-rate-limit-configure.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0004-net-ice-revert-PF-ICE-rate-limit-to-non-queue-group-.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0005-ice-set-ICE_SCHED_DFLT_BURST_SIZE-to-2048.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0006-Change-to-enable-PTP.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0007-net-iavf-not-include-ipv4_port-for-RTE_ETH_RSS_NONFR.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0008-net-ice-add-dst-src-only-support-for-rss-l3-and-l4.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/0009-net-iavf-add-lock-for-VF-commands.patch +pacman -S git base-devel unzip pactoys +pacboy -S openssl:p gcc:p meson:p pkg-config:p json-c:p libpcap:p gtest:p SDL2:p SDL2_ttf:p dlfcn:p ``` -Then apply windows platform dpdk patch +## 4. Install tools + +* Install mman (mmap for windows): ```bash -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0001-Add-DDP-package-load-support-in-windows.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0002-Change-list-remove-and-add-position-to-avoid-race-co.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0003-Mingw-compiler-do-have-same-implementation.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0004-Mingw-do-have-pthread-implementation-change-to-adapt.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0005-To-change-for-windows-trained-pad_interval-pass-in-v.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0006-Add-Windows-10-May-2019-and-newer-version-1GB-huge-p.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0007-Enable-descriptor-prefetch-for-CBDMA-version-3.4.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0008-Windows-need-set-the-timer-resolution-to-maximum-to-.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0009-Windows-dsa-driver-need-set-to-reset-status-first.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0010-Windows-version-currently-no-BPF-support.patch -patch -p1 < {path_to_repo_dir}/Media-Transport-Library/patches/dpdk/22.11/windows/0011-Remove-affinity-binding-for-windows-will-have-perfor.patch +git clone https://github.com/alitrack/mman-win32 +cd mman-win32 +./configure --prefix=$MSYSTEM_PREFIX +make && make install ``` -### 3.2 Build and install DPDK - -Execute the commands below in windows command prompt: +* Install npcap SDK: ```bash -cd C:\path_to\dpdk -meson build --prefix=c:\dpdk -ninja -C build install +wget https://nmap.org/npcap/dist/npcap-sdk-1.12.zip +unzip -d npcap-sdk npcap-sdk-1.12.zip +cp npcap-sdk/Lib/x64/* $MSYSTEM_PREFIX/lib/ ``` -#### 3.2.1 Delete all *.dll.a files in c:\dpdk\lib, and only keep*.a files +* Download and install npcap from . -#### 3.2.2 Find C:\dpdk\lib\pkgconfig\libdpdk.pc, change the libs define to below +## 5. Build DPDK -Libs.private: - -#### 3.2.3 Find C:\dpdk\lib\pkgconfig\libdpdk-libs.pc, change the libs define to below +* Clone the IMTL repository if not: ```bash - -Libs:-L${libdir} -lrte_latencystats -lrte_gso -lrte_bus_pci -lrte_gro -lrte_cfgfile -lrte_bitratestats -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_net_ice -lrte_net_iavf -lrte_common_iavf -lrte_net_i40e -lrte_mbuf -lrte_mempool -lrte_stack -lrte_mempool_stack -lrte_mempool_ring -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lrte_dmadev -lrte_dma_ioat +git clone https://github.com/OpenVisualCloud/Media-Transport-Library.git +cd Media-Transport-Library ``` -## 3.3 Add pkg-config - -### 3.3.1 Download three folders +For all steps below, the default work dir is IMTL repository. -pkg-config_0.26-1 - - -glib_2.28.8-1_win32 - - -gettext-runtime_0.18.1.1-2_win32 - - -### 3.3.2 Install them - -### 3.3.3 Add path to the environment variable as described below just like python, meson and ninja +* Convert symlink patch files to real file: ```bash -C:\path_to\pkg-config_0.26-1\bin\ -C:\path_to\glib_2.28.8-1_win32\bin\ -C:\path_to\gettext-rintime_0.18.1.1-2_win32\bin\ +cd patches/dpdk/23.03 +ls *.patch | xargs -I{} bash -c 'if [[ $(sed -n '1p' "{}") =~ ^../.*\.patch$ ]]; then cp "$(cat "{}")" "{}"; fi' +cd windows +ls *.patch | xargs -I{} bash -c 'if [[ $(sed -n '1p' "{}") =~ ^../.*\.patch$ ]]; then cp "$(cat "{}")" "{}"; fi' ``` -### 3.3.4 Download SDL2 folder - -Download from: - - -#### 3.3.5 Create new environment variable - -PKG_CONFIG_PATH is correct installed and compiled package path for pkg-config searching -For example, c:\sdl2\lib\pkgconfig - -#### 3.3.6 Change the sdl2.pc file - -Change libdir and includedir to your correct install path -Also, change Cflags: -I${includedir} -Dmain=SDL_main - -#### 3.3.7 Download json-c folder - -Download from: - -Uzip the zst file, remove *.dll.a file in lib folder, only keep*.a file, or else you will need json-c.dll when running - -#### 3.3.8 Add the json-c install pkgconfig path to the PKG_CONFIG_PATH environment variable - -For example, c:\json-c\lib\pkgconfig - -#### 3.3.9 Change the json-c.pc file - -Change libdir and includedir to your correct install path - -#### 3.3.10 Download win-pcap folder - -Download from: -, -Uzip the zip file - -Download from: -, -Install the package on the target running machine - -#### 3.3.11 Copy the npcap x64 directory lib files to mingw lib directory,such as - -C:\mingw64\lib - -#### 3.3.12 Copy the npcap include header files to mingw include directory,such as - -C:\mingw64\x86_64-w64-mingw32\include - -#### 3.3.13 Download mman folder - -Download from: - -Uzip the zip file, go to the directory, Execute below command in Git bash +* Clone the DPDK repository and apply patches: ```bash -./configure -/c/mingw64/bin/mingw32-make.exe libmman.a +git clone https://github.com/DPDK/dpdk.git +cd dpdk +git checkout v23.03 +git switch -c v23.03 + +git config user.name "Your Name" # config if not +git config user.email "you@example.com" # config if not +git am ../patches/dpdk/23.03/*.patch +git am ../patches/dpdk/23.03/windows/*.patch ``` -#### 3.3.14 Copy the compiled libmman.a files to mingw lib directory,such as - -C:\mingw64\lib - -#### 3.3.15 Copy the mman include header files to mingw include directory,such as - -C:\mingw64\x86_64-w64-mingw32\include\sys - -#### 3.3.16 Download gtest folder - -Download from: - -Uzip the zst file - -#### 3.3.17 Add the gtest install pkgconfig path to the PKG_CONFIG_PATH environment variable - -#### 3.3.18 Change the gtest.pc file - -Change libdir and includedir to your correct install path - -Download the gtest Dependencies: mingw-w64-x86_64-gcc-libs from: - -Uzip the zst file and copy the libstdc++-6.dll to the directory same as gtest.dll, -gtest can now only link with dll mode, when you run the app, you need copy gtest.dll and libstdc++-6.dll to the directory -same as your app - -Note: please keep the *.dll.a files of the gtest, gtest can not be static linked, do not use libstdc++-6.dll in mingw64 directory - -#### 3.3.19 Download openssl folder - -Download from: - -Uzip the zst file - -#### 3.3.20 Add the openssl install pkgconfig path to the PKG_CONFIG_PATH environment variable +* Build and install DPDK: -#### 3.3.21 Change the openssl.pc file - -Change libdir and includedir to your correct install path -Remove the *.dll.a files,if you keep the*.dll.a files, you need additional libssl-1_1-x64.dll and libcrypto-1_1-x64.dll files - -#### 3.3.22 Download libdl folder - -Download from: - -Uzip the zst file - -#### 3.3.23 Copy the dlfcn.h include header files to mingw include directory,such as - -C:\mingw64\x86_64-w64-mingw32\include - -#### 3.3.24 Copy the libdl.a lib files to mingw lib directory,such as - -C:\mingw64\lib +```bash +cd dpdk +meson setup build +meson install -C build +``` -## 4. Open command prompt goto Media-Transport-Library dir run +## 6. Build IMTL -first set PKGCONFIG path: +* Build and install IMTL lib: ```bash -set PKG_CONFIG_PATH=c:\dpdk\lib\pkgconfig;c:\json-c\lib\pkgconfig +meson setup build +meson install -C build ``` -### 4.1 Build Intel® Media Transport Library +* Build IMTL app: ```bash -meson build --prefix=c:\libmtl -Ddpdk_root_dir=c:\code\dpdk <--- your dpdk source code directory -ninja -C build install +cd app +meson setup build +meson compile -C build ``` -### 4.2 Build app +* Build IMTL tests: ```bash -set PKG_CONFIG_PATH=c:\dpdk\lib\pkgconfig;c:\libmtl\lib\pkgconfig;c:\gtest\lib\pkgconfig;c:\openssl\lib\pkgconfig;c:\json-c\lib\pkgconfig;c:\SDL2\lib\pkgconfig -cd app -meson build -ninja -C build +cd tests +meson setup build +meson compile -C build ``` -### 4.3 Build tests +* Build and install IMTL plugins: ```bash -cd tests -meson build -ninja -C build +cd plugins +meson setup build +meson install -C build ``` + +## 7. Add MSYS2 binary PATH to system environment variables (Optional) + +The MSYS2 path is not in Windows system environment variables by default, if you want to run IMTL apps in PowerShell/CMD, you need to add the paths first. For example, MSYS2 is installed in `C:\msys64`. + +* (optional)Add MSYS2 common toolchain path: `C:\msys64\usr\bin` + +* If the environment is MinGW64, add: `C:\msys64\mingw64\bin` + +* If the environment is UCRT64, add: `C:\msys64\ucrt64\bin` diff --git a/doc/build_WIN_MSYS2.md b/doc/build_WIN_MSYS2.md deleted file mode 100644 index e929e76d..00000000 --- a/doc/build_WIN_MSYS2.md +++ /dev/null @@ -1,134 +0,0 @@ -# Intel® Media Transport Library compilation and build on Windows OS (MSYS2) - -## 1. Introduction - -This document contains instructions for installing and configuring the Intel® Media Transport Library for Windows Operation System in MSYS2 environment. - -## 2. Prerequisites - -* Windows 10 / Windows Server 2019 64-bit or higher - -## 3. Install MSYS2 environment - -* Download and install MSYS2 from . -* Open an MSYS2 MINGW64/UCRT64 shell, all commands in this doc will be run in this shell. -* Update packages: - -```bash -pacman -Syu -``` - -## 4. Install dependencies - -* Install build tools and dependencies: - -```bash -pacman -S git base-devel unzip pactoys -pacboy -S openssl:p gcc:p meson:p pkg-config:p json-c:p libpcap:p gtest:p SDL2:p SDL2_ttf:p dlfcn:p -``` - -## 4. Install tools - -* Install mman (mmap for windows): - -```bash -git clone https://github.com/alitrack/mman-win32 -cd mman-win32 -./configure --prefix=$MSYSTEM_PREFIX -make && make install -``` - -* Install npcap SDK: - -```bash -wget https://nmap.org/npcap/dist/npcap-sdk-1.12.zip -unzip -d npcap-sdk npcap-sdk-1.12.zip -cp npcap-sdk/Lib/x64/* $MSYSTEM_PREFIX/lib/ -``` - -* Download and install npcap from . - -## 5. Build DPDK - -* Clone the IMTL repository if not: - -```bash -git clone https://github.com/OpenVisualCloud/Media-Transport-Library.git -cd Media-Transport-Library -``` - -For all steps below, the default work dir is IMTL repository. - -* Convert symlink patch files to real file: - -```bash -cd patches/dpdk/23.03 -ls *.patch | xargs -I{} bash -c 'if [[ $(sed -n '1p' "{}") =~ ^../.*\.patch$ ]]; then cp "$(cat "{}")" "{}"; fi' -cd windows -ls *.patch | xargs -I{} bash -c 'if [[ $(sed -n '1p' "{}") =~ ^../.*\.patch$ ]]; then cp "$(cat "{}")" "{}"; fi' -``` - -* Clone the DPDK repository and apply patches: - -```bash -git clone https://github.com/DPDK/dpdk.git -cd dpdk -git checkout v23.03 -git switch -c v23.03 - -git config user.name "Your Name" # config if not -git config user.email "you@example.com" # config if not -git am ../patches/dpdk/23.03/*.patch -git am ../patches/dpdk/23.03/windows/*.patch -``` - -* Build and install DPDK: - -```bash -cd dpdk -meson setup build -meson install -C build -``` - -## 6. Build IMTL - -* Build and install IMTL lib: - -```bash -meson setup build -meson install -C build -``` - -* Build IMTL app: - -```bash -cd app -meson setup build -meson compile -C build -``` - -* Build IMTL tests: - -```bash -cd tests -meson setup build -meson compile -C build -``` - -* Build and install IMTL plugins: - -```bash -cd plugins -meson setup build -meson install -C build -``` - -## 7. Add MSYS2 binary PATH to system envorenment variables (Optional) - -The MSYS2 path is not in Windows system envorenment variables by default, if you want to run IMTL apps in PowerShell/CMD, you need to add the paths first. For example, MSYS2 is intalled in `C:\msys64`. - -* (optional)Add MSYS2 common toolchain path: `C:\msys64\usr\bin` - -* If the environment is MinGW64, add: `C:\msys64\mingw64\bin` - -* If the environment is UCRT64, add: `C:\msys64\ucrt64\bin` diff --git a/doc/run_WIN.md b/doc/run_WIN.md index 504b9665..d9aff31f 100644 --- a/doc/run_WIN.md +++ b/doc/run_WIN.md @@ -1,77 +1,92 @@ # Run Guide on Windows -Intel® Media Transport Library required Windows netuio driver Windows virt2phys driver and huge page(windows server 2022) to run +Intel® Media Transport Library requires Windows netuio driver Windows virt2phys driver and huge page to run. ## 1. System setup -### 1.1 Enable test sign in Windows +### 1.1 Enable test sign in Windows if you choose to build non-signed drivers +```powersehll bcdedit /set loadoptions DISABLE_INTEGRITY_CHECKS bcdedit /set TESTSIGNING ON +``` ### 1.2 Add huge page rights in Windows -Open Local Security Policy snap-in, either: -Control Panel / Computer Management / Local Security Policy; -or Win+R, type secpol, press Enter. -Open Local Policies / User Rights Assignment / Lock pages in memory. -Add desired users or groups to the list of grantees. +#### 1.2.1 Option 1: Local Security Policy + +* Control Panel / Computer Management / Local Security Policy ( +or Win+R, type `secpol`, press Enter). + +* Open Local Policies / User Rights Assignment / Lock pages in memory. + +* Add desired users or groups to the list of grantees. Privilege is applied upon next logon. In particular, if privilege has been granted to current user, a logoff is required before it is available. -## 2 Install virt2phys Driver +#### 1.2.2 Option 2: ntright.exe (if Local Security Policy is not available) -### 2.1.1 Download dpdk-kmods pack from +* Download and install rktools from -git://dpdk.org/dpdk-kmods -Compile the virt2phys and netuio project using visual studio 2019 +* Open PowerShell, run: -### 2.1.2 Then, execute command in cmd + ```powersehll + ntrights.exe +r SeLockMemoryPrivilege -u Administrator + ``` -```bash -devcon.exe install virt2phys.inf root\virt2phys -``` +* Reboot to enable it. -### 2.1.3 Make sure that the driver was installed +## 2 Install virt2phys Driver -### 2.1.4 When there is a problem with driver installation are needed more steps +### 2.1 Download dpdk-kmods pack from -Test sign the driver using a test certificate and then boot the Windows in "Test mode", or +git://dpdk.org/dpdk-kmods +Compile the virt2phys and netuio project using visual studio 2019 -Use the boot time option to "Disable driver signature enforcement" +### 2.2 Then, execute command in cmd -### 2.1.5 Manually install virt2phys steps for Windows Server +Get devcon.exe from Windows WDK package (if you don't want WDK, you can refer to for how to get devcon.exe), copy the devcon.exe to your netuio driver folder. -From Device Manager, Action menu, select "Add legacy hardware". +execute command: -It will launch the "Add Hardware Wizard". Click "Next" +```powershell +devcon.exe install virt2phys.inf root\virt2phys +``` -Select second option "Install the hardware that I manually select from a list" +### 2.3 Make sure that the driver was installed -On the next screen, "Kernel bypass" will be shown as a device class +### 2.4 When there is a problem with driver installation are needed more steps -Select it and click "Next". +* Test sign the driver using a test certificate and then boot the Windows in "Test mode", or -Click "Have Disk". +* Use the boot time option to "Disable driver signature enforcement". -Find location of your virt2phys.inf driver. +### 2.5 Manually install virt2phys steps for Windows Server -Select it and click "Next". +* From Device Manager, Action menu, select "Add legacy hardware". +* It will launch the "Add Hardware Wizard". Click "Next". +* Select second option "Install the hardware that I manually select from a list". +* On the next screen, "Kernel bypass" will be shown as a device class. +* Select it and click "Next". +* Click "Have Disk". +* Find location of your virt2phys.inf driver. +* Select it and click "Next". -The previously installed drivers will now be installed for the "Virtual to physical address translator" device +The previously installed drivers will now be installed for the "Virtual to physical address translator" device. -### 2.1.6 Here we just go through next and finish buttons +### 2.6 Here we just go through next and finish buttons ## 3. Steps for netuio driver ### 3.1 Use devcon install netuio driver -Get devcon.exe from Windows WDK package, copy the devcon.exe to your netuio driver folder execute command: -```bash +```powershell devcon.exe update netuio.inf "PCI\VEN_8086&DEV_1592" ``` +You can change "1592" per your NIC type. + ### 3.2 Manually install netuio driver * Go to Device Manager -> Network Adapters. @@ -85,7 +100,7 @@ devcon.exe update netuio.inf "PCI\VEN_8086&DEV_1592" ### 4.1 Update NIC FW and driver to latest version -Refer to +Refer to . ### 4.2 Update the ICE DDP package file: ice.pkg @@ -106,7 +121,7 @@ You can bind the app to the cpu socket 0 ( if your NIC is inserted into the pcie To identify the socket if you do not know it, in the NIC card driver property page, check the bus number, if the number is great than 0x80, then socket 1, else socket 0, for example -```bash +```powershell start /Node 0 /B .\build\app\RxTxApp --config_file config\test_tx_1port_1v.json ``` @@ -118,15 +133,15 @@ Please refer to sections 3, 4, and 5 in the [linux run guide](run.md) for instru ### 6.2 Install windows TAP driver -In the Control Panel->Network and internet->Network Connections, find the "OpenVPN TAP-Windows6" device, set the adaptor IP address, such as 192.168.2.2 +In the Control Panel->Network and internet->Network Connections, find the "OpenVPN TAP-Windows6" device, set the adaptor IP address, such as `192.168.2.2`. ### 6.3 Rebuild and install MTL lib with "-Denable_tap=true" ```bash -meson tap_build --prefix=c:\libmtl -Ddpdk_root_dir=${DPDK_SRC_DIR} -Denable_tap=true +meson tap_build -Ddpdk_root_dir=${DPDK_SRC_DIR} -Denable_tap=true ninja -C tap_build install ``` ### 6.4 Check if Ping is working -Ping 192.168.2.2 from other machine in the same network such as 192.168.2.3, if have reply, the TAP works. +Ping `192.168.2.2` from other machine in the same network such as `192.168.2.3`, if have reply, the TAP works. diff --git a/doc/vm_WIN.md b/doc/vm_WIN.md index 7c166a08..d7cee178 100644 --- a/doc/vm_WIN.md +++ b/doc/vm_WIN.md @@ -67,7 +67,7 @@ After the installation, you can detach the virtio iso and windows iso from cdrom ### 2.2 Build and run IMTL -See [Windows build guide](build_WIN_MSYS2.md) and [Windows run guide](run_WIN.md). +See [Windows build guide](build_WIN.md) and [Windows run guide](run_WIN.md). When installing netuio driver, use below command for iavf: diff --git a/lib/meson.build b/lib/meson.build index 690e00be..0c42c2dc 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -55,6 +55,8 @@ if is_windows mtl_link_c_args += ['-Wl,--whole-archive'] mtl_link_c_args += [dpdklibs.stdout().strip().split()] mtl_link_c_args += ['-Wl,--no-whole-archive'] + # generate .def file to be converted to .lib for msvc + mtl_link_c_args += ['-Wl,--output-def,libmtl.def'] endif if cc.has_argument('-mavx2')