MacOS下编译libtiff时Clang无法生成可执行文件的问题求助
Let's break this down clearly: those "no input files" messages you're seeing aren't the root cause of your build failure—they're side effects of outdated compatibility logic in the libtiff 3.9.6 configure script. Here's the full breakdown:
First: What's causing the "no input files" errors?
Looking at your config.log, those errors stem from two failed compiler version checks in the old configure script:
- The script runs
cc -V: This is a GCC-specific flag, but Clang doesn't support it. When Clang rejects the unrecognized flag, it also notes there are no input files (since the command only requested version info without providing source code). - Next it runs
cc -qversion: This is a flag for IBM's XL compiler, which Clang also doesn't recognize. Again, the "no input files" message is just a secondary, harmless note here.
These are just compatibility warnings from a legacy script that wasn't updated to handle Clang properly. The actual build failure comes from a separate, critical issue:
The real problem: Linker can't find -lSystem
The error that's actually stopping your build is:
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1
This happens when macOS can't locate the system SDK (part of Xcode's command line tools), which provides core system libraries like libSystem.dylib.
Fixes to resolve the issue
Follow these steps to get your build working:
1. Ensure Xcode Command Line Tools are fully installed
Run this in your terminal to install or verify the tools:
xcode-select --install
If they're already installed, you'll see a confirmation message. If not, follow the prompts to complete installation, then restart your terminal.
2. Set the correct Xcode SDK path
First check your current SDK path:
xcode-select -p
It should return /Applications/Xcode.app/Contents/Developer. If it doesn't, set it with:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
3. Work around libtiff's outdated configure script
Since libtiff 3.9.6 is very old (released in 2012), it doesn't handle Clang's defaults well. Add these flags to your CMake configuration for libtiff to force it to use the correct SDK:
If you're using ExternalProject_Add in your CMakeLists.txt:
ExternalProject_Add(libtiff URL http://download.osgeo.org/libtiff/libtiff-3.9.6.tar.gz CONFIGURE_ARGS --disable-debug --disable-dependency-tracking CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc CFLAGS="-isysroot $(xcrun --show-sdk-path)" )
If you're using FetchContent:
# Set C flags to use the correct SDK before declaring libtiff set(CMAKE_C_FLAGS "-isysroot $(xcrun --show-sdk-path)" CACHE STRING "" FORCE) FetchContent_Declare(libtiff URL http://download.osgeo.org/libtiff/libtiff-3.9.6.tar.gz )
4. Clean and rebuild from scratch
Delete your existing build directory to clear any broken cached configurations:
rm -rf build
Then re-run CMake and make:
mkdir build && cd build cmake .. make
Summary
The "no input files" errors are just noise from an old configure script that doesn't know how to check Clang's version properly. The real fix is ensuring your Xcode command line tools are installed correctly, and forcing libtiff to use macOS's system SDK during compilation.
内容的提问来源于stack exchange,提问作者ziad_dp

