如何在不依赖UUID的情况下编译Fontconfig并生成其dylib库
Hey, I’ve helped folks work through this exact scenario before—building Fontconfig as a dylib without any UUID dependencies can be tricky because the build system defaults to looking for UUID support. Let’s fix this with a few targeted changes:
1. Update your configure command to explicitly disable UUID
Fontconfig’s configure script has a built-in flag to skip UUID detection entirely. Add --without-uuid to your existing command, so it looks like this:
./configure --disable-docs --disable-dependency-tracking --disable-silent-rules --enable-shared --with-add-fonts="/System/Library/Fonts","/Library/Fonts","~/Library/Fonts" --without-uuid
This tells the build system to completely ignore UUID-related libraries and code paths, which should get past that stuck check step.
2. Patch source code if configure still throws errors
In rare cases, even with --without-uuid, some hardcoded UUID references might linger in the source (most commonly in src/fcfs.c, where UUIDs are used to generate unique font cache IDs). If you hit compile errors related to UUID functions like uuid_generate, you can replace that logic with a fallback:
- Open
src/fcfs.cand find the section where UUIDs are generated - Replace the UUID code with an alternative unique identifier, like combining the file’s inode and modification time:
// Replace uuid_generate(&uuid) and related code with this: struct stat st; char id[64]; if (stat(font_path, &st) == 0) { snprintf(id, sizeof(id), "%llu-%llu", (unsigned long long)st.st_ino, (unsigned long long)st.st_mtime); } else { // Fallback if stat fails strncpy(id, "fc-fallback-id", sizeof(id)-1); id[sizeof(id)-1] = '\0'; }
This gives you a unique enough identifier without relying on UUID libraries.
3. Clean and rebuild from scratch
Before re-running configure, make sure you clear any cached build files to avoid leftover dependencies:
make clean && rm -rf autom4te.cache # If you're building from a git checkout, run this first: # ./autogen.sh
Then run the updated configure command, followed by:
make && make install
This should produce a Fontconfig dylib that’s completely free of UUID dependencies.
内容的提问来源于stack exchange,提问作者Martin

