You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nokogumbo gem的C实现提交导致Gentoo Linux编译失败

Why switching #include <...> to "..." broke Nokogumbo compilation on Gentoo Linux

Great question—this tiny change might seem harmless, but it's a perfect example of how C's include syntax behaves differently across system setups, especially when dealing with distros like Gentoo that prioritize system libraries over bundled code. Let's break this down in plain terms since you're new to C:

The core difference between #include <header.h> and #include "header.h"

C compilers treat these two syntaxes very differently when searching for header files:

  • #include <file.h>: Tells the compiler to look first in system-wide include directories (think /usr/include on Linux). This is the standard way to reference headers from libraries installed globally on your system.
  • #include "file.h": Tells the compiler to look first in the same directory as the current source file, then fall back to system directories. This is meant for your project's own local headers that live alongside your source code.

Why this broke Gentoo

Gentoo's package manager (Portage) is designed to use system-installed versions of libraries whenever possible, rather than letting individual packages bundle their own copies. For Nokogumbo, this means it relies on the system's Gumbo HTML parser library (installed via the dev-libs/gumbo package) instead of including Gumbo's headers directly in the gem's source code.

Before the commit:

  • #include <gumbo.h> worked because the compiler was directed to search system directories where Gentoo installs Gumbo's headers. The gem's build setup (its extconf.rb script) was configured to add the correct system include path to the compiler's search list, so it found the headers without any issues.

After the commit:

  • #include "gumbo.h" makes the compiler first check the Nokogumbo gem's source directory. Since Gentoo doesn't bundle Gumbo's headers here, the compiler can't find them. Even though it should fall back to system directories, the gem's build configuration might not be passing the necessary include paths correctly when using the quote syntax, or the system headers are in a subdirectory that the quote-based include doesn't account for. Either way, the compiler throws an error because it can't locate the required headers.

How to fix this

For Gentoo users or package maintainers, the most straightforward fix is to revert the change back to using angle brackets for those three includes. Alternatively, adjust the gem's build script to explicitly add the system Gumbo include path (like -I/usr/include/gumbo) to the compiler flags, which would let the quote-based includes find the headers properly.

内容的提问来源于stack exchange,提问作者svoop

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:32:59