Windows平台下使用CygWin64开发Linux程序,如何获取<linux/ip.h>头文件对应的依赖包
Hey there, I’ve been in your shoes before—trying to build Linux-targeted code on Cygwin and hitting header file roadblocks. Let’s get this sorted out quickly:
First off, the util-linux package you installed is for user-space Linux utilities, not the kernel headers you need. The <linux/ip.h> header lives in the Linux kernel header set, which Cygwin provides via a specific package. Here’s what you need to do:
- Fire up the Cygwin Setup executable (the same one you used to install Cygwin initially).
- Click through the setup steps until you reach the package selection screen.
- In the search bar at the top, type
linux-api-headers. You’ll see this package listed under the "Devel" category. - Click on the "Skip" label next to it to select the latest available version for installation.
- Finish the setup process—let it download and install the package.
Once that’s done, you’ll find <linux/ip.h> in /usr/include/linux/ directory. Your compiler should automatically pick this up when you build your code, since /usr/include is part of the default include path for GCC in Cygwin.
If you still run into issues during compilation, double-check that you’re not overriding the include path with custom -I flags that might exclude /usr/include. But in most cases, installing linux-api-headers should fix the missing header problem.
内容的提问来源于stack exchange,提问作者felixoben

