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

编译安装Aruco 3.0.10后pkg-config使用错误前缀的问题求助

Fixing pkg-config Path Issue After Compiling Aruco 3.0.10

I’ve run into this exact kind of path misalignment before with cmake-based builds—let’s walk through how to fix it step by step:

Step 1: Identify Where pkg-config Is Pulling the Wrong .pc File

First, let’s confirm which aruco.pc file pkg-config is actually using, because it’s likely picking up a leftover one from your temporary build directory instead of the installed version in /usr/local:

pkg-config --variable=pcfiledir aruco

If the output points to a /tmp/... directory, that’s the root of the problem.

Step 2: Clean Up Leftover Build Files & Fix Environment Variables

  • Remove the temporary build directory (since it’s holding the rogue .pc file):
    # If you still have the directory path, delete it directly. If not, run:
    rm -rf $(find /tmp -name "aruco-3.0.10" 2>/dev/null)
    
  • Check and fix your PKG_CONFIG_PATH:
    Sometimes the temporary directory gets added to your pkg-config search path accidentally. Run this to check:
    echo $PKG_CONFIG_PATH
    
    If you see a /tmp/ entry, remove it with:
    export PKG_CONFIG_PATH=$(echo $PKG_CONFIG_PATH | tr ':' '\n' | grep -v '/tmp' | tr '\n' ':')
    

Step 3: Re-Build & Re-Install with Explicit CMake Prefix

The issue often happens because cmake uses the build directory’s absolute path during configuration, even if you intend to install to /usr/local. Let’s recompile with an explicit prefix to force correct path generation:

# Recreate the build environment (or navigate back to your existing build dir if it's still intact)
cd $(mktemp -d)
version="3.0.10"
pkg="aruco-${version}.zip"
url="https://netix.dl.sourceforge.net/project/aruco/3.0.0/${pkg}"
wget -O $pkg $url
unzip $pkg
cd aruco-${version}
mkdir -p build && cd build

# Clean previous cmake cache and set explicit install prefix
rm -f CMakeCache.txt
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..

# Recompile and install
make -j$(nproc)
sudo make install

Step 4: Update System Library Cache

After reinstalling, refresh the system’s library cache to ensure changes are picked up:

sudo ldconfig

Step 5: Verify the Fix

Run these commands to confirm pkg-config now points to the correct /usr/local paths:

# Check library paths
pkg-config aruco --libs
# Expected output: -L/usr/local/lib -laruco

# Check include paths
pkg-config aruco --cflags
# Expected output: -I/usr/local/include/aruco -I/usr/local/include

If you still see issues, search for any leftover aruco.pc files across your system and delete them:

find / -name aruco.pc 2>/dev/null | grep -v "/usr/local/lib/pkgconfig" | xargs rm -f

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 10:02:45