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

ARMv8.1 Chromebook的Termux编译Taskwarrior 2.5.1遇__atomic_fetch_add_4未定义引用

Fixing __atomic_fetch_add_4 Undefined Reference When Compiling task-2.5.1 on ARMv8.1 Chromebook (Termux)

The issue you're hitting is common on ARM targets when using libc++ (which you're specifying with -stdlib=libc++): the atomic operations used in Nibbler.cpp require linking against the libatomic library, and CMake isn't adding this dependency automatically. Manually editing link.txt doesn't work because CMake regenerates that file every time you run make, overwriting your changes. Here's how to fix it properly:

Solution 1: Modify the Project's CMakeLists.txt

This is the most reliable approach, as it embeds the dependency directly into the build configuration:

  1. Navigate to the src directory of your task-2.5.1 source tree:
    cd /data/data/com.termux/files/home/src/task-2.5.1/src
    
  2. Open the CMakeLists.txt file (the one defining the lex_executable target) in a text editor like nano.
  3. Locate the target_link_libraries section for lex_executable. It should resemble this:
    target_link_libraries(lex_executable
        libtask.a
        commands/libcommands.a
        columns/libcolumns.a
        libtask.a
        gnutls
        uuid
    )
    
  4. Add atomic to the end of the list to explicitly link against libatomic:
    target_link_libraries(lex_executable
        libtask.a
        commands/libcommands.a
        columns/libcolumns.a
        libtask.a
        gnutls
        uuid
        atomic
    )
    
  5. Save the file, then re-run CMake to regenerate build files:
    cd ..
    cmake .
    
  6. Re-run make VERBOSE=1—you should see -latomic included in the linker command, and the undefined reference errors should resolve.

Solution 2: Pass Linker Flags Directly to CMake

If you prefer not to modify the project's CMake files, specify the linker flag when initializing the build:

  1. Clean your existing build directory (optional but recommended to avoid stale files):
    cd /data/data/com.termux/files/home/src/task-2.5.1
    make clean
    rm CMakeCache.txt
    
  2. Re-run CMake with the CMAKE_EXE_LINKER_FLAGS parameter set to include -latomic:
    cmake -DCMAKE_EXE_LINKER_FLAGS="-latomic" .
    
  3. Proceed with compiling as before:
    make VERBOSE=1
    

Why This Works

On ARM platforms, libc++ doesn't link against libatomic by default, even though it's required for certain atomic operations like __atomic_fetch_add_4. By explicitly adding the atomic library to the linker dependencies—either via CMakeLists.txt or command-line flags—you're telling the linker to include the necessary atomic operation implementations.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 07:43:04