Skip to content

Conversation

Copy link

Copilot AI commented Oct 19, 2025

Problem

The build was failing with undefined reference errors for PullOCIModel and FreeString symbols when linking executables that depend on the common library:

/usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): undefined reference to `PullOCIModel'
/usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): undefined reference to `FreeString'

This affected multiple targets including:

  • llama-parallel
  • llama-batched
  • llama-lookahead
  • llama-lookup
  • llama-embedding
  • llama-eval-callback

Root Cause

The common library is a static library that includes oci.cpp, which calls functions from the Go-based OCI library (liboci.a). The OCI library and other dependencies were linked to common with PRIVATE visibility:

target_link_libraries(${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)

When a static library links to dependencies privately, those dependencies are not propagated to executables that link against it. This meant that while common itself could compile with access to the OCI symbols, executables linking to common didn't automatically get liboci.a, resulting in undefined references at link time.

Solution

Changed the linkage of LLAMA_COMMON_EXTRA_LIBS from PRIVATE to PUBLIC:

target_link_libraries(${TARGET} PUBLIC ${LLAMA_COMMON_EXTRA_LIBS} llama Threads::Threads)

With PUBLIC linkage, executables that link to the common static library now automatically receive all transitive dependencies, including:

  • The OCI Go library (liboci.a)
  • CURL libraries
  • Build info object files
  • Platform-specific frameworks (on macOS)

This is the correct CMake pattern for static libraries with external dependencies.

Testing

  • ✅ Full project builds successfully without errors
  • ✅ All previously failing targets now link and execute correctly
  • ✅ Verified OCI symbols are properly resolved in executables (nm shows defined symbols)
  • ✅ Test suite passes (37/40 tests, with unrelated network/model file failures)
  • ✅ No code review or security scan issues

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ggml.ai
    • Triggering command: /home/REDACTED/work/llama.cpp/llama.cpp/build/bin/test-arg-parser (dns block)
    • Triggering command: ./build/bin/test-arg-parser (dns block)
  • huggingface.co
    • Triggering command: /home/REDACTED/work/llama.cpp/llama.cpp/build/bin/test-thread-safety -hf ggml-org/models -hff tinyllamas/stories15M-q4_0.gguf -ngl 99 -p The meaning of life is -n 128 -c 256 -ub 32 -np 4 -t 2 (dns block)
    • Triggering command: /home/REDACTED/work/llama.cpp/llama.cpp/build/bin/llama-eval-callback --hf-repo ggml-org/models --hf-file tinyllamas/stories260K.gguf --model stories260K.gguf --prompt hello --seed 42 -ngl 0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Fix this build:

2025-10-19T16:07:21.2537450Z [ 66%] Linking CXX executable ../../bin/llama-parallel
2025-10-19T16:08:28.9607459Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function nlohmann::json_abi_v3_12_0::detail::parse_error nlohmann::json_abi_v3_12_0::detail::parse_error::create<decltype(nullptr), 0>(int, nlohmann::json_abi_v3_12_0::detail::position_t const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, decltype(nullptr)) [clone .isra.0]': 2025-10-19T16:08:29.0107835Z oci.cpp:(.text+0x1188): undefined reference to PullOCIModel'
2025-10-19T16:08:29.0522439Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function oci_pull_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': 2025-10-19T16:08:29.0926875Z oci.cpp:(.text+0x12e4): undefined reference to FreeString'
2025-10-19T16:08:29.2301162Z collect2: error: ld returned 1 exit status
2025-10-19T16:08:29.2645893Z gmake[2]: *** [examples/lookahead/CMakeFiles/llama-lookahead.dir/build.make:106: bin/llama-lookahead] Error 1
2025-10-19T16:08:29.2823311Z gmake[1]: *** [CMakeFiles/Makefile2:1582: examples/lookahead/CMakeFiles/llama-lookahead.dir/all] Error 2
2025-10-19T16:08:29.3001425Z gmake[1]: *** Waiting for unfinished jobs....
2025-10-19T16:08:29.3931059Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function nlohmann::json_abi_v3_12_0::detail::parse_error nlohmann::json_abi_v3_12_0::detail::parse_error::create<decltype(nullptr), 0>(int, nlohmann::json_abi_v3_12_0::detail::position_t const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, decltype(nullptr)) [clone .isra.0]': 2025-10-19T16:08:29.4157193Z oci.cpp:(.text+0x1188): undefined reference to PullOCIModel'
2025-10-19T16:08:29.4360871Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function oci_pull_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': 2025-10-19T16:08:29.4570279Z oci.cpp:(.text+0x12e4): undefined reference to FreeString'
2025-10-19T16:08:29.6781309Z collect2: error: ld returned 1 exit status
2025-10-19T16:08:29.6958093Z gmake[2]: *** [examples/batched/CMakeFiles/llama-batched.dir/build.make:106: bin/llama-batched] Error 1
2025-10-19T16:08:29.7141021Z gmake[1]: *** [CMakeFiles/Makefile2:1304: examples/batched/CMakeFiles/llama-batched.dir/all] Error 2
2025-10-19T16:08:29.9080880Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function nlohmann::json_abi_v3_12_0::detail::parse_error nlohmann::json_abi_v3_12_0::detail::parse_error::create<decltype(nullptr), 0>(int, nlohmann::json_abi_v3_12_0::detail::position_t const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, decltype(nullptr)) [clone .isra.0]': 2025-10-19T16:08:29.9300548Z oci.cpp:(.text+0x11fc): undefined reference to PullOCIModel'
2025-10-19T16:08:29.9502524Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function oci_pull_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': 2025-10-19T16:08:29.9713300Z oci.cpp:(.text+0x136c): undefined reference to FreeString'
2025-10-19T16:08:30.1858950Z collect2: error: ld returned 1 exit status
2025-10-19T16:08:30.2064968Z gmake[2]: *** [examples/lookup/CMakeFiles/llama-lookup.dir/build.make:106: bin/llama-lookup] Error 1
2025-10-19T16:08:30.2165999Z gmake[1]: *** [CMakeFiles/Makefile2:1619: examples/lookup/CMakeFiles/llama-lookup.dir/all] Error 2
2025-10-19T16:08:30.4263383Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function nlohmann::json_abi_v3_12_0::detail::parse_error nlohmann::json_abi_v3_12_0::detail::parse_error::create<decltype(nullptr), 0>(int, nlohmann::json_abi_v3_12_0::detail::position_t const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, decltype(nullptr)) [clone .isra.0]': 2025-10-19T16:08:30.4428373Z oci.cpp:(.text+0x1188): undefined reference to PullOCIModel'
2025-10-19T16:08:30.4591948Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function oci_pull_model(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': 2025-10-19T16:08:30.4697304Z oci.cpp:(.text+0x12e4): undefined reference to FreeString'
2025-10-19T16:08:30.4806423Z /usr/bin/ld: ../../common/libcommon.a(oci.cpp.o): in function `nlohmann::json_abi_v3_12_0::detail::parse_error nlohmann::json_abi_v3_12_0::detail::parse_error::create<decltype(nullptr), 0>(int, nlohmann::json_abi_v3_12_0::detail::position_t const&, std::__cxx11::basic_string<char, std::char_traits, std:...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

So we can pull from any OCI registry, add authentication, etc.

Add docker-style progress bars and resumable downloads to OCI pulls

Update documentation with progress bars and resumable downloads info

Signed-off-by: Eric Curtin <[email protected]>
Copilot AI self-assigned this Oct 19, 2025
@ericcurtin ericcurtin force-pushed the integrate-go-containerregistry-library branch from e5bd64a to 3a27e5c Compare October 19, 2025 18:11
Copilot AI changed the title [WIP] Fix build issues related to undefined references Fix OCI library linking error by making common library dependencies PUBLIC Oct 19, 2025
Copilot AI requested a review from ericcurtin October 19, 2025 18:13
Copilot finished work on behalf of ericcurtin October 19, 2025 18:13
@ericcurtin ericcurtin force-pushed the integrate-go-containerregistry-library branch 7 times, most recently from e4b192d to 2935963 Compare October 19, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants