git2-rs: Build fails on macOS Sierra (10.12.6) due to undefined symbols
Building git2-rs failes to build on my system, a macOS Sierra 10.12.6. (However, I see that travis correctly builds the same checkout)
Some system information:
$ rustc --version
rustc 1.21.0 (3b72af97e 2017-10-09)
$ rustup --version
rustup 1.6.0 ( )
$ cargo --version
cargo 0.22.0 (3423351a5 2017-10-06)
$ cc --version
Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
The cli-output:
$ cargo test
Compiling libgit2-sys v0.6.16 (file:///Users/tvermeir/devel/rust-sandbox/git2-rs/libgit2-sys)
Compiling git2 v0.6.8 (file:///Users/tvermeir/devel/rust-sandbox/git2-rs)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-m64" "-L" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/git2-607ffebb677e754d.0.o" "-o" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/git2-607ffebb677e754d" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/git2-607ffebb677e754d.crate.allocator.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps" "-L" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/build/libgit2-sys-4d562b53da46a05e/out/lib" "-L" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/libbitflags-05a76aa5d1c1cf07.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libtest-db9e5401f64b6e8c.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/liburl-66962c7e15a9d3db.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/libpercent_encoding-e8491e011d12f115.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/libidna-0b5a450752e57dd0.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/libunicode_bidi-36e10feff83f59e7.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/liblibgit2_sys-89dbd6098f7d321f.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/libtempdir-2d0a2dcb33406b89.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-2f170e25267c318b.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/libmatches-1ebd31cb2b60a18b.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/libunicode_normalization-50b1c2d2498198a6.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/liblibz_sys-f1d6b4bae61f4d14.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/librand-58382db5cc56e62c.rlib" "/Users/tvermeir/devel/rust-sandbox/git2-rs/target/debug/deps/liblibc-ffafbea21f5b9743.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libterm-ce9e0ebf918666dd.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-a4cb6a5cdd439628.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-518d4b2a103f523e.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-bf40ace258e8c400.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-ae44887349ff2666.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_system-232b33d68f8d8793.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-547714683d755c8a.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-ee8c941dfe26cb03.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_unicode-ed28cc142b5072c0.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librand-d0d8801a35685ad6.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-2e89074855638f2b.rlib" "/Users/tvermeir/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-3cf04f5feabf9eee.rlib" "-l" "iconv" "-framework" "Security" "-framework" "CoreFoundation" "-l" "z" "-l" "System" "-l" "resolv" "-l" "pthread" "-l" "c" "-l" "m"
= note: Undefined symbols for architecture x86_64:
"_libiconv", referenced from:
_git_path_iconv in liblibgit2_sys-89dbd6098f7d321f.rlib(path.c.o)
"_libiconv_close", referenced from:
_git_path_iconv_clear in liblibgit2_sys-89dbd6098f7d321f.rlib(path.c.o)
"_libiconv_open", referenced from:
_git_path_iconv_init_precompose in liblibgit2_sys-89dbd6098f7d321f.rlib(path.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
error: linking with `cc` failed: exit code: 1
|
error: linking with `cc` failed: exit code: 1
... (and much more of the same)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 27 (4 by maintainers)
Commits related to this issue
- wip, iconv problems: dyld: Symbol not found: _iconv dyld: Symbol not found: _iconv Referenced from: /usr/lib/libcups.2.dylib Expected in: /sw/lib/libiconv.2.dylib in /usr/lib/libcups.2.dylib R... — committed to fink/fink-distributions by bcully 6 years ago
- edenapi: do not dependent on eagerepo Summary: eagerepo -> metalog -> git2 -> libgit2-sys -> libgit2 conflicts with edenfs' non-Rust libgit2 dependency. Rust git2 crate does not seem to provide a way... — committed to facebook/sapling by quark-zju 3 years ago
- Fix libiconv conflicts with MacPorts and Rust Solution found here: https://github.com/rust-lang/git2-rs/issues/263#issuecomment-510708093 — committed to SharkBaitDLS/dotfiles by deleted user 3 months ago
For what it is worth, if people still search for this issue (as I have), here is what worked for me:
In my
.profile, I now haveIt may suck to end up looking in that lib first, even for things that don’t depend on -liconv, but I’m happy to have the commuter do a tiny bit of extra build for each build then for me to figure out which cases this is needed in.
I’ve also filed a MacPorts request for a libiconv-select to help deal with the problem as it interacts with other things beyond rust.
I think this should be re-opened as I’ve also encountered the issue when attempting to install
cargo-editandcargo-outdatedon macOS Big Sur, withlibiconvinstalled via MacPorts.Setting
RUSTFLAGSas suggested in https://github.com/rust-lang/git2-rs/issues/263#issuecomment-510708093 did not work for me since this version of macOS does not provide/usr/lib/libiconv.ahowever the following workaround was successful: https://stackoverflow.com/a/34140282/4247209I faced the same situation for
cargo-updatebut I cannot find/Library/Frameworks/libiconv.framework.Does anyone solve this issue by another way?
It’s expected that git2-rs builds its own copy of libgit2 and doesn’t use the system version, as the system version is likely incompatible