Let's build DPDK in Windows with MinGW-w64

There's a library named DPDK(Data Plane Development Kit. https://www.dpdk.org). Previously led by Intel, now it's a project from the Linux Foundation. The aim of this project is to make a packet from NIC to bypass kernel and go to userspace right away. Though you need to make your hands quite dirty, it's worth it.

So what? DPDK started to support Windows from 19.05(ta-da!). Though it supports only the basics, the team plans to broaden supported features more and more.

Well, there's a problem, though - you need LLVM+MSVC+meson+ninja to build the library. Even the official documentation explains that way. But you know what? You can replace LLVM+MSVC to MinGW-w64. Yes, you can use MinGW-w64+meson+ninja as your toolchain to build DPDK in Windows.

First, let's see meson commmands.
  • set CC=gcc
  • meson -Dexample=helloworld -Dc_args="-D_WIN32_WINNT=0x0601" build
  • cd build
After this, when ninja.build file is created, replace /imp: to --out-implib, and remove -Wl containing /def.  After that, just run ninja to get your library ready to serve.

Quite easy, huh?

Windows에서 MinGW-w64로 DPDK를 빌드해보자

DPDK(Data Plane Development Kit)란 라이브러리가 있습니다(https://www.dpdk.org/). 과거에는 인텔이 주도했고, 지금은 리눅스 재단에서 열심히 밀어주고 있는 프로젝트죠. 이게 뭔가 하면, 네트워크 카드에서 패킷이 날아오면 이걸 커널을 통과하지 않고 바로 userspace로 보내줄 수 있는 환경을 만들어줍니다. 대신 잔손이 엄청 많이 가긴 하지만, 그럴만한 가치가 있는 라이브러리이기도 하죠.

그런데, 이 DPDK가 19.05부터는 Windows를 지원하기 시작했습니다(두둥). 지금 당장은 기본적인 기능밖에 지원되지 않습니다만, DPDK쪽에서는 차근차근 지원 가능한 기능을 늘려가겠다는 입장입니다.

단지 지금 당장 문제라면...... 이걸 빌드하려면 LLVM+MSVC+meson+ninja가 필요하다는 거죠. 공식 메뉴얼에도 저걸로 빌드하라고 되어 있고요. 그런데, LLVM+MSVC를 MinGW-w64로 대체할 수 있습니다. 즉, MinGW-w64+meson+ninja로 빌드가 가능합니다.

일단 meson쪽의 빌드 커맨드는 이렇습니다.
  • set CC=gcc
  • meson -Dexample=helloworld -Dc_args="-D_WIN32_WINNT=0x0601" build
  • cd build
이후 ninja.build 파일이 생성되면 /imp:를 --out-implib=으로 고치고, /def가 포함된 -Wl 구문을 모두 지워주시면 됩니다. 그 이후 ninja를 실행하면 빌드 완료!

어때요, 참 쉽죠? (..??)

블로그를 이전합니다

뭐, 이런 작은 변방의 블로그에 관심있으신 분들은 아무도 없으시리라 생각합니다만...... (웃음) 블로그 플랫폼을 블로거에서 dev.to로 옮겼습니다. 새 URL은 아래와 같습니다: https://dev.to/teminian 새로운 거처에서 뵙겠습니...

Popular in Code{nested}