libgit2 / libgit2/libgit2

build failed if -DUSE_ICONV=ON is given

Open
#6,472 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
10.6k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

Reproduction steps
curl -LO https://github.com/libgit2/libgit2/archive/v1.5.1.tar.gz
tar vxf v1.5.1.tar.gz
cd libgit2-1.5.1

cmake \
    -S . \
    -B build.d \
    -DBUILD_TESTS=OFF \
    -DBUILD_EXAMPLES=OFF \
    -DBUILD_SHARED_LIBS=OFF \
    -DUSE_SSH=OFF \
    -DUSE_ICONV=ON \
    -DUSE_HTTPS=OpenSSL \
    -DREGEX_BACKEND=pcre2 \
    -DCMAKE_FIND_ROOT_PATH='/home/leleliu008/.ppkg/installed/openssl;/home/leleliu008/.ppkg/installed/pcre2;/home/leleliu008/.ppkg/installed/zlib;/home/leleliu008/.ppkg/installed/libiconv' \
    -DCMAKE_C_FLAGS=-I/home/leleliu008/.ppkg/installed/openssl/include \
    -DCMAKE_VERBOSE_MAKEFILE=ON \
    -DCMAKE_FIND_DEBUG_MODE=ON \
    -DCMAKE_FIND_USE_CMAKE_PATH=ON \
    -DCMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH=OFF \
    -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF \
    -DCMAKE_FIND_USE_CMAKE_SYSTEM_PATH=OFF \
    -DCMAKE_FIND_USE_INSTALL_PREFIX=OFF \
    -DCMAKE_INCLUDE_PATH=/include \
    -DCMAKE_LIBRARY_PATH=/lib \
    -DCMAKE_PROGRAM_PATH='/bin;/sbin'
cmake --build build.d
Expected behavior

ca be successfully built.

Actual behavior
/usr/bin/ld: ../util/CMakeFiles/util.dir/fs_path.c.o: in function `git_fs_path_iconv_init_precompose':
/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/src/util/fs_path.c:982: undefined reference to `libiconv_open'
/usr/bin/ld: ../util/CMakeFiles/util.dir/fs_path.c.o: in function `git_fs_path_iconv_clear':
/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/src/util/fs_path.c:990: undefined reference to `libiconv_close'
/usr/bin/ld: ../util/CMakeFiles/util.dir/fs_path.c.o: in function `git_fs_path_iconv':
/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/src/util/fs_path.c:1015: undefined reference to `libiconv'
collect2: error: ld returned 1 exit status
gmake[2]: *** [src/cli/CMakeFiles/git2_cli.dir/build.make:596: git2_cli] Error 1
gmake[2]: Leaving directory '/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/build.d'
gmake[1]: *** [CMakeFiles/Makefile2:326: src/cli/CMakeFiles/git2_cli.dir/all] Error 2
gmake[1]: Leaving directory '/home/leleliu008/tmp/tmp.d/tmp.d/libgit2-1.5.1/build.d'
gmake: *** [Makefile:139: all] Error 2

cmake-config.log
cmake-build.log

Version of libgit2 (release number or SHA1)

https://github.com/libgit2/libgit2/archive/v1.5.1.tar.gz

Operating system(s) tested

ubuntu-22.10

more

I noticed that cmake config log say Found Iconv: provided by libc, this is not correct, I using a seperate libiconv, I do not use the iconv functions in libc. It seems that libiconv.so was not linked into the git2 due to it was expected to be provided by libc but actually it was in a seperate library.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the CMake configuration with USE_ICONV=ON and inspect the Iconv detection and link settings, then review src/util/fs_path.c around the reported iconv calls. Done means the libgit2 build succeeds when iconv is supplied as a separate libiconv library rather than provided by libc.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.