After an update to the new macOS (Ventura 13.1, M1 Pro) version rust project started to crash on build when tries to link libomp. The error on cargo build -vv:
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-arch" "arm64" "/var/folders/_p/tgbl9k457tvbjbpxmb2q3r1m0000gn/T/rustc1sq6Z5/symbols.o" "/Users/vikulikov/projects/{project_path}/target/debug/deps/{project}-ec57ac4e6d4eed12.10102az2qpqlnssx.rcgu.o" "/Users/vikulikov/projects/{project_path}/target/debug/deps/{project}-ec57ac4e6d4eed12.10pmcgcmusc5twvn.rcgu.o" "/Users/vikulikov/projects/{project_path}/target/debug/deps/{project}-ec57ac4e6d4eed12.33ebzcr429zv4r69.rcgu.o" "-L" "/Users/vikulikov/projects/{project_path}/target/debug/deps" "-L" "/Users/vikulikov/projects/{project_path}/target/debug/build/ring-66285374768a0289/out" "-L" "/Users/vikulikov/projects/{project_path}/target/debug/build/clickhouse-rs-cityhash-sys-56b125abd43a1bed/out" "-L" "/Users/vikulikov/projects/{project_path}/target/debug/build/lz4-sys-b41f36414fcf3d57/out" "-L" "/Users/vikulikov/projects/{project_path}/target/debug/build/lightgbm-sys-34cf0c5853566b8c/out/lib" "-L" "/Users/vikulikov/projects/{project_path}/target/debug/build/lightgbm-sys-34cf0c5853566b8c/out" "-L" "/Users/vikulikov/projects/{project_path}/target/debug/build/bzip2-sys-55a2969129b4a854/out/lib" "-L" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librayon-a368ce40113bc0f7.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librayon_core-d9e15259c12109dd.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/lib{project_dir}-c76f044f35528d72.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtracing_loki-d0184819565b7bc6.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsnap-306d8cec31a52cce.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtracing_serde-a73889d4392e2361.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libloki_api-ddd536117f3c02da.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libprost_types-572832ad507f9de0.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libprost-e068f62c28ccc8b2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/liborder_stat-25a20551870d634c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpancakeswap-4e0d114d9a2a76be.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers-a219b92e6641dbe1.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers_middleware-d29117ee6c7944b4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers_signers-8eaf51178d999ed1.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libeth_keystore-b991f15c61299d1b.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libaes-85ce4a53054918f3.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libopaque_debug-69d537144a36dc89.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libscrypt-688fa31c4f28c63b.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsalsa20-7fa37dfb872be400.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpassword_hash-ee6e3baff74b42c1.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpbkdf2-3d9567eefa71c45a.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libctr-f37779e2de156ab2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcipher-56165c31f9471ba2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcoins_bip39-4d851dd8aaf70dac.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpbkdf2-5bb0582222c9e070.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpassword_hash-e0ed827d8e9fd003.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbase64ct-74280d3beea8da8e.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbitvec-9423a5447ef68001.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libradium-a089b6a53f21f784.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcoins_bip32-3a1c2a5c010b854c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbs58-c0142c1f88c6f8b7.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcoins_core-245c3e946073f305.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libblake2-e9ec6e9f373c1ef4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbase64-908fea8ab5c201dd.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libripemd-07f318d495654f0c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbase58check-5df8d10f35a6bee5.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsha2-d597d4e6775fc17f.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libdigest-96df25a861e1e14c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libopaque_debug-c5a545cdb63802d6.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfake_simd-66c05d9faa110044.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libblock_buffer-ca3c152eaf8294ac.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libgeneric_array-4658500995f0dba1.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libblock_padding-8c899def0159c457.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbyte_tools-04232adcec1f2ed9.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbase58-61c3db63dadefe01.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbech32-ecfa67b0df0f995e.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_locks-a0acad40751b0c2c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers_etherscan-cbcf7d4d7670ce82.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsemver-10e716672a01011f.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libserde_aux-fd3d015d0a4edb77.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers_contract-85e3f04ebf35ee9e.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers_providers-573f02d8178a7edc.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_timer-fb57d40fad211b41.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtracing_futures-d170a033d12065b3.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers_addressbook-2a0b7a4a7e07b1d5.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethers_core-0019fb6c6704b519.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libunicode_xid-e7d1530a327bea76.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libstrum-0a5428bb6883f13c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libk256-35436dc2a3673601.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libecdsa-83480df40be69291.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librfc6979-fae22233353d569d.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsignature-2767ee0e150ba21c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libelliptic_curve-82183223f196e8bf.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsec1-0ddd593266f18fbb.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpkcs8-1b692c412fa3ede8.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libspki-9fe5635ab5e0291b.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libder-19631b5bae8ff186.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbase16ct-45afe28af36516d3.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libgroup-4b637aed44be1a61.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libff-092feacb084533b4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcrypto_bigint-4dceeffb77fde972.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libzeroize-6d1a20a9695545ca.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsyn-a0b333f36cf6933a.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libquote-564fbbf32ce874a1.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libproc_macro2-a12129456c79b3ae.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libunicode_ident-2df767b08b5dee4e.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libproc_macro-00b05ec0a97de84e.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libconvert_case-7ad0534d8c5fd8c3.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfastrlp-256bc78a1ef74915.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethabi-d8f8b392b37cd582.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethereum_types-0eb195605b40513c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libethbloom-1e54de4eae147b61.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtiny_keccak-0cb69878e52df2f3.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libprimitive_types-4f54843cfb523fba.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libimpl_codec-8e47d3c4d0d7172d.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libparity_scale_codec-0d2e9771e57e0938.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbyte_slice_cast-7479fed5ff548fa4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libimpl_serde-6a5277220fa398c6.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libimpl_rlp-da0374252df098bf.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librlp-240681309e2ba0a2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfixed_hash-964906ceb0260a33.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librustc_hex-22afa64d3d0ca991.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsha3-874e48672e2f596d.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libkeccak-ad55d88ffa7ab68c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libuint-3a101f0d60a79d53.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcrunchy-aa9525a478410cd6.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libstatic_assertions-0ff83d9301a80122.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/liberased_serde-c1e6cb738a619760.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbinance_{project_dir}-861a3e967128a5d3.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libhmac_sha256-06695515fb30ad01.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtokio_native_tls-4c9f6996cf1ea42b.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtokio-86cdf7ae56108f25.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsignal_hook_registry-1e2cd83343c3c9db.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libnum_cpus-c7ce2c947fb8cdf4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsocket2-4352fe09b768a757.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libmio-290b15fdaef97a66.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libparking_lot-34cf09bf4119fbd2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libparking_lot_core-d1fa6b2701b27516.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsmallvec-25a503f6c5b2115b.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/liblock_api-007f4f757f665560.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libscopeguard-e5de70d0869a1c62.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_util-b48bc9683ec1862f.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libmemchr-6c9fbfeda127ffa9.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_io-31c6c3fdbfd7acd1.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libslab-875bd9101045b6dd.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_channel-20a3c3a00df83455.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpin_project_lite-ebcedf82ec43c8a1.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_sink-03bac378879c749a.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_task-ee914422cb186d20.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpin_utils-fe0d75987f40efa5.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfutures_core-cf6b91f091126cd4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtungstenite-ca8867ea48f31ee9.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbase64-63d35bb8646f0242.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librand-90b2f68f9b08d326.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librand_chacha-b44402712ed3dace.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libppv_lite86-697eeaf5f72102e4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librand_core-de8033ba78482ef2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libgetrandom-b3a5e67bd72e9479.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libnative_tls-f4934c5623c8a8a9.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtempfile-367f4cfc6447abfe.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfastrand-59e99e6b8d72a8ac.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libremove_dir_all-a13bce8a768cc08e.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsecurity_framework-538b9df5ab088483.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbitflags-6db4b7a1a2354e6b.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsecurity_framework_sys-eb98a88952287665.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcore_foundation-ec930b180bb57bc2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/liblazy_static-0773c577324b701d.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libutf8-0c5e5daffc553b62.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbyteorder-faf1acd975834e27.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsha1-9f15f43c46c73cd0.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libdigest-5d770a9e9e6ea149.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libsubtle-2e8596ffab1ab75f.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libconst_oid-834c0e0b1604df37.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libblock_buffer-4f4761ca28d48ae4.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcrypto_common-584dd06845a293e9.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libgeneric_array-dc3be67fb5b90830.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtypenum-2b09589daa71d801.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libhttparse-9d194949d06437af.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libthiserror-7ecb4a699b8920d3.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/liburl-936a0b47da399149.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libidna-b5faa9c2ece42de8.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libunicode_normalization-1c164c59614d379d.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtinyvec-5417aa7aadc151a2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtinyvec_macros-7959d4d6443a0458.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libunicode_bidi-106b62c41d379400.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libform_urlencoded-49bcd040a7c16576.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libpercent_encoding-477b6fb21f40da87.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/liblog-6ddcd53f5312ef38.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcfg_if-f043d77383bd547c.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libhttp-cf4bb2360a1f828f.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libbytes-73183855b42e1e92.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libfnv-a96d0f7e079db9b2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libchrono-08619b9cfb303392.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libiana_time_zone-8212bb41be21572b.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcore_foundation_sys-9b0150f66877fcf2.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libnum_integer-bafe1031ea8e0662.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtime-08e3f249427e3b17.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/liblibc-fc26f4dd5713c66f.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libcapnp-51990ee9b5227c5a.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libtoml-fe00432fe23ba335.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libserde_json-16a6e5424b301f9e.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libryu-5b49562fe5a7a929.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libitoa-1a7b4806aa6816d6.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/librust_decimal-81a1e6b928a08798.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libserde-b10975cd22772c38.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libarrayvec-f160a33dcc17dc71.rlib" "/Users/vikulikov/projects/{project_path}/target/debug/deps/libnum_traits-f8699bb15f4e50a3.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-8b48f6cefff7b1fb.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-77aeaad8f850e496.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-4374cc9e76b48de5.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-71ce82846aaede9b.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-88478a43231eec41.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-219a0c42f67a2534.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-967edde4cff44b15.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-5e9bad2c7ec1f53a.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-f2d3de7828f2e1f2.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-39feb0179b2f197f.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-fe7523d51d4e2154.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libadler-1fb439e2b08a54ae.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-0ece1873dc3050cd.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-1094a874bdfc7dbb.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-8cd76113b92d6775.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-3a7cb21921429c0e.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-5b42fb3902d391c7.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-b495777441600026.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-cba95c4386a21469.rlib" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-b8f163a13cf94b5d.rlib" "-lc++" "-lomp" "-framework" "CoreFoundation" "-framework" "SystemConfiguration" "-lc++" "-framework" "Security" "-framework" "Security" "-framework" "CoreFoundation" "-liconv" "-lSystem" "-lc" "-lm" "-L" "/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/vikulikov/projects/{project_path}/target/debug/deps/{project}-ec57ac4e6d4eed12" "-Wl,-dead_strip" "-nodefaultlibs"
= note: ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
warning: `{project}` (bin "{project}") generated 63 warnings
error: could not compile `{project}` due to previous error; 63 warnings emitted
Caused by:
process didn't exit successfully: `CARGO=/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo CARGO_BIN_NAME={project} CARGO_CRATE_NAME={project} CARGO_MANIFEST_DIR=/Users/vikulikov/projects/{project_path} CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME={project} CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.10.7 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=10 CARGO_PKG_VERSION_PATCH=7 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 DYLD_FALLBACK_LIBRARY_PATH='/Users/vikulikov/projects/{project_path}/target/debug/deps:/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Users/vikulikov/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Users/vikulikov/lib:/usr/local/lib:/usr/lib' rustc --crate-name {project} --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=ec57ac4e6d4eed12 -C extra-filename=-ec57ac4e6d4eed12 --out-dir /Users/vikulikov/projects/{project_path}/target/debug/deps -C incremental=/Users/vikulikov/projects/{project_path}/target/debug/incremental -L dependency=/Users/vikulikov/projects/{project_path}/target/debug/deps --extern anyhow=/Users/vikulikov/projects/{project_path}/target/debug/deps/libanyhow-3c4562411ebdf4c7.rlib --extern chrono=/Users/vikulikov/projects/{project_path}/target/debug/deps/libchrono-08619b9cfb303392.rlib --extern crossbeam=/Users/vikulikov/projects/{project_path}/target/debug/deps/libcrossbeam-fd8c6961f76e5aac.rlib --extern csv=/Users/vikulikov/projects/{project_path}/target/debug/deps/libcsv-1e27cf452055291a.rlib --extern itertools=/Users/vikulikov/projects/{project_path}/target/debug/deps/libitertools-b33196f4ae79cd67.rlib --extern {project_dir}=/Users/vikulikov/projects/{project_path}/target/debug/deps/lib{project_dir}-c76f044f35528d72.rlib --extern {project_dir}_core=/Users/vikulikov/projects/{project_path}/target/debug/deps/lib{project_dir}_core-ff32a9a09b2fee14.rlib --extern order_stat=/Users/vikulikov/projects/{project_path}/target/debug/deps/liborder_stat-25a20551870d634c.rlib --extern parking_lot=/Users/vikulikov/projects/{project_path}/target/debug/deps/libparking_lot-34cf09bf4119fbd2.rlib --extern rayon=/Users/vikulikov/projects/{project_path}/target/debug/deps/librayon-a368ce40113bc0f7.rlib --extern rust_decimal=/Users/vikulikov/projects/{project_path}/target/debug/deps/librust_decimal-81a1e6b928a08798.rlib --extern rust_decimal_macros=/Users/vikulikov/projects/{project_path}/target/debug/deps/librust_decimal_macros-67e08731edac8129.dylib --extern serde=/Users/vikulikov/projects/{project_path}/target/debug/deps/libserde-b10975cd22772c38.rlib --extern serde_derive=/Users/vikulikov/projects/{project_path}/target/debug/deps/libserde_derive-60aad29f37dfad23.dylib --extern serde_json=/Users/vikulikov/projects/{project_path}/target/debug/deps/libserde_json-16a6e5424b301f9e.rlib --extern tokio=/Users/vikulikov/projects/{project_path}/target/debug/deps/libtokio-86cdf7ae56108f25.rlib --extern toml=/Users/vikulikov/projects/{project_path}/target/debug/deps/libtoml-fe00432fe23ba335.rlib -L native=/Users/vikulikov/projects/{project_path}/target/debug/build/ring-66285374768a0289/out -L native=/Users/vikulikov/projects/{project_path}/target/debug/build/clickhouse-rs-cityhash-sys-56b125abd43a1bed/out -L native=/Users/vikulikov/projects/{project_path}/target/debug/build/lz4-sys-b41f36414fcf3d57/out -L /Users/vikulikov/projects/{project_path}/target/debug/build/lightgbm-sys-34cf0c5853566b8c/out/lib -L native=/Users/vikulikov/projects/{project_path}/target/debug/build/lightgbm-sys-34cf0c5853566b8c/out -L native=/Users/vikulikov/projects/{project_path}/target/debug/build/bzip2-sys-55a2969129b4a854/out/lib` (exit status: 1)
It needs the lib due to lightgbm-rs lib used in the project. I believe I've already tried all the technics needed for lightgbm to compile from the internet, even reset the OS. Installed the llvm and gcc seperately, etc.
Actions after reset:
# rust installing
brew install cmake libomp lightgbm
brew link --force libomp
cargo build
Maybe it is good to mention that lightgbm and lightgbm-sys libs are successfuly built. And crash is happenning in the very end of the build.
Actually problem occured because homebrew made libomp keg-only.
They suggest to add couple of env variables for compilers to find the lib:
For compilers to find libomp you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"
But cargo does not respect LDFLAGS variable. So I've tried to add a RUSTFLAGS variable as:
export RUSTFLAGS=-L/opt/homebrew/opt/libomp/lib
and it worked.
Related
We were using grpc 1.15.0 for long time and linked to application compiled with C++11.
We try to upgrade grpc to 1.46.5 (base on documentation gRPC C++ 1.46 will be the last release supporting C++11)
I had simple test program that only calls
std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel("https://127.0.0.1:9999", ssl_creds);
With 1.15.0 it was compiled without any errors
g++ adam_test1.cpp -std=c++11 -I/home/adam/grpc1.15.0/obj/linux_x86-64/3rd/include -L/home/adam/grpc1.15.0/obj/linux_x86-64/3rd/lib64 -l:libgrpc++.a -l:libgrpc.a -l:libgpr.a -l:libaddress_sorting.a -lcrypto -lssl -lcares -lz -pthread -o adam_test1
The same with 1.46.5 show many undefined reference.
Tried even add some libabsl but still failing
g++ adam_test1.cpp -std=c++11 -I/home/adam/grpc1.46.5/obj/linux_x86-64/3rd/include -L/usr/lib64 -L/home/adam/grpc1.46.6/obj/linux_x86-64/3rd/lib64 -l:libgrpc++.a -l:libgrpc.a -l:libgpr.a -l:libaddress_sorting.a -l:libabsl_base.a -l:libabsl_cord.a -l:libabsl_status.a -l:libabsl_strings.a -l:libabsl_synchronization.a -lcrypto -lssl -lcares -lz -pthread -lstdc++ -o adam_test2
some logs
/home/adam/grpc1.46.5/obj/linux_x86-64/3rd/lib64/libgrpc.a(client_channel.cc.o): In function `grpc_core::ClientChannel::CreateOrUpdateLbPolicyLocked(grpc_core::RefCountedPtr<grpc_core::LoadBalancingPolicy::Config>, absl::lts_20211102::optional<std::string> const&, grpc_core::Resolver::Result)':
client_channel.cc:(.text+0x8c01): undefined reference to `absl::lts_20211102::internal_statusor::Helper::HandleInvalidStatusCtorArg(absl::lts_20211102::Status*)'
/home/adam/grpc1.46.5/obj/linux_x86-64/3rd/lib64/libgrpc.a(client_channel.cc.o): In function `std::_Function_handler<void (), grpc_core::ClientChannel::SubchannelWrapper::WatcherWrapper::OnConnectivityStateChange()::{lambda()#1}>::_M_invoke(std::_Any_data const&)':
client_channel.cc:(.text._ZNSt17_Function_handlerIFvvEZN9grpc_core13ClientChannel17SubchannelWrapper14WatcherWrapper25OnConnectivityStateChangeEvEUlvE_E9_M_invokeERKSt9_Any_data[_ZNSt17_Function_handlerIFvvEZN9grpc_core13ClientChannel17SubchannelWrapper14WatcherWrapper25OnConnectivityStateChangeEvEUlvE_E9_M_invokeERKSt9_Any_data]+0x4ce): undefined reference to `absl::lts_20211102::optional_internal::throw_bad_optional_access()'
/home/adam/grpc1.46.5/obj/linux_x86-64/3rd/lib64/libgrpc.a(client_channel.cc.o): In function `absl::lts_20211102::StatusOr<absl::lts_20211102::InlinedVector<grpc_core::ServerAddress, 1ul, std::allocator<grpc_core::ServerAddress> > >::StatusOr()':
client_channel.cc:(.text._ZN4absl12lts_202111028StatusOrINS0_13InlinedVectorIN9grpc_core13ServerAddressELm1ESaIS4_EEEEC2Ev[_ZN4absl12lts_202111028StatusOrINS0_13InlinedVectorIN9grpc_core13ServerAddressELm1ESaIS4_EEEEC5Ev]+0x44): undefined reference to `absl::lts_20211102::internal_statusor::Helper::HandleInvalidStatusCtorArg(absl::lts_20211102::Status*)'
/home/adam/grpc1.46.5/obj/linux_x86-64/3rd/lib64/libgrpc.a(lb_policy.cc.o): In function `grpc_core::LoadBalancingPolicy::UpdateArgs::operator=(grpc_core::LoadBalancingPolicy::UpdateArgs&&)':
lb_policy.cc:(.text+0x69e): undefined reference to `absl::lts_20211102::internal_statusor::Helper::HandleInvalidStatusCtorArg(absl::lts_20211102::Status*)'
/home/adam/grpc1.46.5/obj/linux_x86-64/3rd/lib64/libgrpc.a(lb_policy.cc.o): In function `grpc_core::LoadBalancingPolicy::UpdateArgs::operator=(grpc_core::LoadBalancingPolicy::UpdateArgs const&)':
lb_policy.cc:(.text+0x9ac): undefined reference to `absl::lts_20211102::internal_statusor::Helper::HandleInvalidStatusCtorArg(absl::lts_20211102::Status*)'
/home/adam/grpc1.46.5/obj/linux_x86-64/3rd/lib64/libgrpc.a(lb_policy_registry.cc.o): In function `grpc_core::LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(grpc_core::Json const&, grpc_error**)':
The grpc and absl are also compiled with -std=c++11. What should be the correct cmake command to build libgrpc.a with C++11 and what other abls libs need to be linked when using it ?
git submodule update --init ${GRPC_SOURCE}/third_party/re2/ ${GRPC_SOURCE}/third_party/abseil-cpp/
# Install absl
mkdir -p "third_party/abseil-cpp/cmake/build"
pushd "third_party/abseil-cpp/cmake/build"
cmake -std=c++11 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PROD_DIR} -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ../..
make -j4 install
popd
cmake \
-std=c++11 \
-DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=1 \
-DCMAKE_BUILD_TYPE=Release \
-DgRPC_INSTALL=ON \
-DgRPC_BUILD_TESTS=OFF \
-DgRPC_CARES_PROVIDER=package \
-DgRPC_ABSL_PROVIDER=package \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_RE2_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=package \
-DgRPC_ABSL_PROVIDER=module \
-DgRPC_INSTALL_SUPPORTED_FROM_MODULE=ON \
-Dc-ares_DIR=${CARES_DIR}/lib/cmake/c-ares \
-DgRPC_INSTALL_LIBDIR=${SYS_LIB_DIR} \
-D_gRPC_PROTOBUF_PROTOC=${PROTO_DIR} \
-DCMAKE_PREFIX_PATH=${OPENSSL_DIR}\\;${PROTO_DIR}\\;${ZLIB_DIR} \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-R/opt/3rd/lib64 -lprotoc -lprotobuf" \
-DCMAKE_INSTALL_PREFIX=${PROD_DIR} \
-DCMAKE_CXX_FLAGS="-I${PROTO_DIR}/include -I${OPENSSL_DIR}/include -I./third_party/cares -L${PROTO_DIR}/lib -L${OPENSSL_DIR}/lib" \
-DCMAKE_C_FLAGS="-I${PROTO_DIR}/include -I${OPENSSL_DIR}/include -L${PROTO_DIR}/lib -L${OPENSSL_DIR}/lib" \
-LAH \
../..
make && make install
I was able to build after adding libabsl in correct order and also need to run on server with newer libstdc++.so that knows __cxa_throw_bad_array_length
g++ adam_test1.cpp -std=c++11 -I/home/adam/obj/linux_x86-64/3rd/include -L/usr/lib64 -L/home/adam/obj/linux_x86-64/3rd/lib64 -l:libgrpc++.a -l:libgrpc.a -l:libgpr.a -l:libaddress_sorting.a -l:libabsl_cord.a -l:libabsl_status.a -l:libabsl_strings.a -l:libabsl_synchronization.a -l:libabsl_statusor.a -l:libabsl_bad_optional_access.a -l:libabsl_bad_variant_access.a -l:libabsl_time.a -l:libabsl_time_zone.a -l:libabsl_throw_delegate.a -l:libabsl_hash.a -l:libabsl_raw_logging_internal.a -l:libabsl_log_severity.a -l:libabsl_strings_internal.a -l:libabsl_malloc_internal.a -l:libre2.a -l:libupb.a -l:libabsl_base.a -l:libabsl_spinlock_wait.a -l:libabsl_symbolize.a -l:libabsl_str_format_internal.a -l:libabsl_random_internal_randen.a -l:libabsl_random_internal_randen_hwaes.a -l:libabsl_random_internal_randen_hwaes_impl.a -l:libabsl_random_internal_randen_slow.a -l:libabsl_random_internal_pool_urbg.a -l:libabsl_random_internal_platform.a -l:libabsl_random_internal_seed_material.a -l:libabsl_random_seed_gen_exception.a -l:libabsl_cord.a -l:libabsl_cord_internal.a -l:libabsl_cordz_functions.a -l:libabsl_cordz_info.a -l:libabsl_int128.a -l:libabsl_demangle_internal.a -l:libabsl_stacktrace.a -l:libabsl_debugging_internal.a -l:libabsl_cordz_handle.a -l:libabsl_city.a -l:libabsl_low_level_hash.a -l:libabsl_exponential_biased.a -lcrypto -lssl -lcares -lz -pthread -lstdc++ -o adam_test2
bash-4.4# nm -D /usr/lib64/libstdc++.so.6.0.25 | grep throw_bad
00000000000c02c0 T _ZSt16__throw_bad_castv
00000000000c0280 T _ZSt17__throw_bad_allocv
00000000000c0300 T _ZSt18__throw_bad_typeidv
00000000000c0240 T _ZSt21__throw_bad_exceptionv
00000000000c0720 T _ZSt25__throw_bad_function_callv
00000000000949e0 T __cxa_throw_bad_array_length
00000000000954e0 T __cxa_throw_bad_array_new_length
While running cargo build, I'm getting the following error:
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.0.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.1.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.10.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.11.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.12.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.13.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.14.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.15.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.2.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.3.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.4.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.5.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.6.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.7.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.8.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.migrations_macros.2g6ue3dg-cgu.9.rcgu.o" "-o" "/home/jarvis/SRC/grid/target/debug/deps/libmigrations_macros-24cc179ad0cdafd6.so" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.3xjhulvvd33umm2i.rcgu.o" "/home/jarvis/SRC/grid/target/debug/deps/migrations_macros-24cc179ad0cdafd6.479uqkygm96t55vg.rcgu.o" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/jarvis/SRC/grid/target/debug/deps" "-L" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/jarvis/SRC/grid/target/debug/deps/libsyn-3ee1b9a4d6995c1a.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libquote-849401de171008b7.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libproc_macro2-4431be3eb037870a.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libunicode_xid-373664510327a5cc.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-bba0624c33176ddd.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libmigrations_internals-7f9f79f1a7c23e47.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libdiesel-260ed13c59074541.rlib" "/home/jarvis/SRC/grid/target/debug/deps/liblibsqlite3_sys-de81366d49fa3d10.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libpq_sys-906759194dd6661c.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libserde_json-22c2837401b823a3.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libryu-c299d28f346c44ca.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libitoa-03464e37801631ae.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libserde-2784118073042576.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libr2d2-cf95ef9b2bd10f2c.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libscheduled_thread_pool-ad478afbdee29c90.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libparking_lot-873742aff8280e98.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libparking_lot_core-4da5ea6806b95c53.rlib" "/home/jarvis/SRC/grid/target/debug/deps/liblibc-1083c34519682e1b.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libsmallvec-e310e2c157142037.rlib" "/home/jarvis/SRC/grid/target/debug/deps/liblock_api-c5b0a39665108282.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libscopeguard-4eb98674ce111148.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libinstant-a66b52fcbf3b13e3.rlib" "/home/jarvis/SRC/grid/target/debug/deps/liblog-c34c04d5bf05faba.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libcfg_if-5027c5fda945db67.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libbyteorder-a6db7e07f13316c2.rlib" "/home/jarvis/SRC/grid/target/debug/deps/libbitflags-f14a0d5eed0a3c48.rlib" "-Wl,--start-group" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6f77337c1826707d.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e238540f8faf9927.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-78f8506dd5004913.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-c0e64497deb085aa.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-217a514dc8d845c6.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-65e4f8df4b8bbd73.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-fec1b74170245419.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-e74f867eb2f15322.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-72a374d36f3d0a31.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-cb9206ed96de54c3.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-33ee81149d314805.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-2e8740599b11634b.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-241cf59851357bea.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-edc29aa8c04b480f.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-6a141406945fda5a.rlib" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2408224b4af46d83.rlib" "-Wl,--end-group" "/home/jarvis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d36087076e1dd756.rlib" "-Wl,-Bdynamic" "-lsqlite3" "-lpq" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
= note: /usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
error: aborting due to previous error
error: could not compile `migrations_macros`
Caused by:
process didn't exit successfully: `rustc --crate-name migrations_macros /home/jarvis/.cargo/registry/src/github.com-1ecc6299db9ec823/migrations_macros-1.4.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=24cc179ad0cdafd6 -C extra-filename=-24cc179ad0cdafd6 --out-dir /home/jarvis/SRC/grid/target/debug/deps -L dependency=/home/jarvis/SRC/grid/target/debug/deps --extern migrations_internals=/home/jarvis/SRC/grid/target/debug/deps/libmigrations_internals-7f9f79f1a7c23e47.rlib --extern proc_macro2=/home/jarvis/SRC/grid/target/debug/deps/libproc_macro2-4431be3eb037870a.rlib --extern quote=/home/jarvis/SRC/grid/target/debug/deps/libquote-849401de171008b7.rlib --extern syn=/home/jarvis/SRC/grid/target/debug/deps/libsyn-3ee1b9a4d6995c1a.rlib --extern proc_macro --cap-lints allow` (exit code: 1)
Does anyone know a fix to this?
I have tried all similar things by Googling them, none worked out.
Thanks.
I think your error originates from the fact that:
ld does not know about where your project libs are located. You have to place it into ld's known directories or specify the full path of your library by -L parameter to the linker.
Check this answer:
cpp: usr/bin/ld: cannot find -l<nameOfTheLibrary>
I'm trying to get Rust debugging to work with the JetBrains debugger.
Similar to this question, I noticed the MSVC toolchain isn't supported. I follow the instructions available there and in the JetBrains blog, and get a hello world program to debug, using a Cygwin toolchain for running and debugging.
However, whenever I use a crate that has, as I believe, bindings to native C/C++, the linker fails. This output is the output received when trying to use the ssh2 crate and running the command D:/Programs/Rust/Cargo/bin/cargo.exe run --color=always --package rust_manual --bin rust_manual --verbose (without the 80 preceding warnings):
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
|
= note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\crt2.o" "D:\\Programs\\
Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "D:\\
Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.2il83ncbprx9skxc.rcgu.o" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.2tkb1dtkdvpzvru8.rcgu.o" "D:\\Documents\\rust_manual\\
target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.38mlr7whhiedxpa9.rcgu.o" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.3mv2p2964hms7hcw.rcgu.o" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rus
t_manual-e02c4017dbb04ce1.oyp82k1tv9dpo03.rcgu.o" "-o" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.exe" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.1n9qmwpghqvw10
ei.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "D:\\Documents\\rust_manual\\target\\debug\\deps" "-L" "D:\\Programs\\Rust\\Cargo\\registry\\src\\github.com-1ecc6299db9ec823\\winapi-x86_64-pc-windows-gnu-0.4.0\\lib" "-L" "D:\\D
ocuments\\rust_manual\\target\\debug\\build\\libssh2-sys-611fa0ef83ad9897\\out\\build" "-L" "D:\\Documents\\rust_manual\\target\\debug\\build\\libz-sys-0bd5febd50380866\\out\\build" "-L" "D:\\Programs\\Rust\\Rustup\\toolchains\\stab
le-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "D:\\Documents\\rust_manual\\target\\debug\\deps\\liblinked_hash_map-8ccaf07e1678ba81.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libfs2-
7cdf4dce3545590b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libaes_gcm_siv-7f08f4ec229f0194.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libaes-9e69959843670351.rlib" "D:\\Documents\\rust_manual\\target\\debu
g\\deps\\libaes_soft-85e91b74f1d42369.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libbyteorder-59f20df4b329d08b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libopaque_debug-77ca4cb51d8100fa.rlib" "D:\\Document
s\\rust_manual\\target\\debug\\deps\\libzeroize-bab8662dce816576.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libpolyval-0f2876d6fb299760.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libuniversal_hash-295cab4c7
b6658eb.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libsubtle-19f12b0836f68a71.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libaead-ef3c7269241d4b63.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libb
lock_cipher-662444e0b79f5644.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libgeneric_array-8edaebd677632f76.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libtypenum-1251f48f890b7d62.rlib" "D:\\Documents\\rust_ma
nual\\target\\debug\\deps\\libserde_json-53f81e6916eb8e26.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libryu-c8e41e31d4a509cb.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libitoa-903fb6c5622b5617.rlib" "D:\\Do
cuments\\rust_manual\\target\\debug\\deps\\libserde-4d09c2dcdbb1d8b3.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libssh2-7df6425f87af870e.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libparking_lot-07aaede0978
bcf2e.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libparking_lot_core-476c2f592babd25d.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libsmallvec-5b2a8d31eb1a4c6d.rlib" "D:\\Documents\\rust_manual\\target\\debug
\\deps\\liblock_api-7a323e635f8733ad.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libscopeguard-6c6d401b1f6f82b5.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib" "D:\\Documents
\\rust_manual\\target\\debug\\deps\\liblibz_sys-5c6fdfaf87470695.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\librand-952ff6682f89685d.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\librand_chacha-0619462aab8ab8c
f.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libppv_lite86-dc7a8f001990536b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\librand_core-29c3a2129db92df7.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\l
ibgetrandom-60ce90fab31a9998.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libnotify-a3f8496c1768c614.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libwalkdir-01728b165c663904.rlib" "D:\\Documents\\rust_manual\\t
arget\\debug\\deps\\libsame_file-bade0aa981bdf286.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libwinapi_util-aa42252baaa29f06.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibc-408386b57fa89aa8.rlib" "D:\\Do
cuments\\rust_manual\\target\\debug\\deps\\libfiletime-85a1a02ff2eb4f83.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libwinapi-fc941a2b370d489b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libcfg_if-cf58d0d3cd0
e6fed.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libbitflags-288950b807dfd7f7.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libbase64-e64b24a18f7239bc.rlib" "-Wl,--start-group" "D:\\Programs\\Rust\\Rustup\\too
lchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-447f0e6919e87703.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic
_unwind-6691a7d28fd5ead6.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-ee4714732ebaf9a3.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_
64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-e062de0dbb254b6a.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libbac
ktrace-2bc81dc380687e4b.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libbacktrace_sys-53b5dac028b62d7c.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x
86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-cb491f3ffc25ac52.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-9499
c77410f0cb84.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-cb2a1962c04b6646.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-g
nu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-c582a1654a681be9.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-2285fe2f7f9a72ec.rlib" "D:\\Progr
ams\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-1a51942af531248c.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\ru
stlib\\x86_64-pc-windows-gnu\\lib\\libcore-d7ecf429ccc8dc70.rlib" "-Wl,--end-group" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-4fc9e886634ace
c6.rlib" "-Wl,-Bdynamic" "-lbcrypt" "-lcrypt32" "-luser32" "-lntdll" "-ladvapi32" "-lwinapi_advapi32" "-lwinapi_cfgmgr32" "-lwinapi_fwpuclnt" "-lwinapi_gdi32" "-lwinapi_kernel32" "-lwinapi_msimg32" "-lwinapi_ntdll" "-lwinapi_opengl3
2" "-lwinapi_synchronization" "-lwinapi_user32" "-lwinapi_winspool" "-lwinapi_ws2_32" "-ladvapi32" "-lws2_32" "-luserenv" "-lmingwex" "-lmingw32" "-lmsvcrt" "-lmsvcrt" "-luser32" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lgcc" "-l
msvcrt" "-lkernel32" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
= note: ld: cannot find -lntdll
error: aborting due to previous error; 80 warnings emitted
error: could not compile `rust_manual`.
Caused by:
process didn't exit successfully: `rustc --crate-name rust_manual --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=e02c4017dbb04ce1 -C
extra-filename=-e02c4017dbb04ce1 --out-dir D:\Documents\rust_manual\target\debug\deps -C incremental=D:\Documents\rust_manual\target\debug\incremental -L dependency=D:\Documents\rust_manual\target\debug\deps --extern aes_gcm=D:\Docu
ments\rust_manual\target\debug\deps\libaes_gcm-46686bd39b60c02f.rlib --extern aes_gcm_siv=D:\Documents\rust_manual\target\debug\deps\libaes_gcm_siv-7f08f4ec229f0194.rlib --extern base64=D:\Documents\rust_manual\target\debug\deps\lib
base64-e64b24a18f7239bc.rlib --extern fs2=D:\Documents\rust_manual\target\debug\deps\libfs2-7cdf4dce3545590b.rlib --extern linked_hash_map=D:\Documents\rust_manual\target\debug\deps\liblinked_hash_map-8ccaf07e1678ba81.rlib --extern
notify=D:\Documents\rust_manual\target\debug\deps\libnotify-a3f8496c1768c614.rlib --extern rand=D:\Documents\rust_manual\target\debug\deps\librand-952ff6682f89685d.rlib --extern rand_core=D:\Documents\rust_manual\target\debug\deps\l
ibrand_core-29c3a2129db92df7.rlib --extern serde=D:\Documents\rust_manual\target\debug\deps\libserde-4d09c2dcdbb1d8b3.rlib --extern serde_json=D:\Documents\rust_manual\target\debug\deps\libserde_json-53f81e6916eb8e26.rlib --extern s
sh2=D:\Documents\rust_manual\target\debug\deps\libssh2-7df6425f87af870e.rlib -L native=D:\Programs\Rust\Cargo\registry\src\github.com-1ecc6299db9ec823\winapi-x86_64-pc-windows-gnu-0.4.0\lib -L native=D:\Documents\rust_manual\target\
debug\build\libssh2-sys-611fa0ef83ad9897\out\build -L native=D:\Documents\rust_manual\target\debug\build\libz-sys-0bd5febd50380866\out\build` (exit code: 1)
The reason for this error, I believe, is summarized in the GCC-WARNING.txt file:
gcc.exe contained in this folder cannot be used for compiling C files - it is only used as a linker. In order to be able to compile projects containing C code use the GCC provided by MinGW or Cygwin.
I tried setting the toolchain to use the correct linker. The cargo documentation says that the config file allows me to do this with the following lines:
[target.x86_64-pc-windows-gnu]
linker = "D:\\Programs\\Cygwin\\bin\\gcc.exe"
Again, this works fine without the ssh2 crate, but fails with the following output when the crate is enabled;
error: linking with `D:\Programs\Cygwin\bin\gcc.exe` failed: exit code: 1
|
= note: "D:\\Programs\\Cygwin\\bin\\gcc.exe" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\crt2.o" "D:
\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu
\\lib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.2il83ncbprx9skxc.rcgu.o" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.2tkb1dtkdvpzvru8.rcgu.o" "D:\\Documents\\r
ust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.38mlr7whhiedxpa9.rcgu.o" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.3mv2p2964hms7hcw.rcgu.o" "D:\\Documents\\rust_manual\\target\\debu
g\\deps\\rust_manual-e02c4017dbb04ce1.oyp82k1tv9dpo03.rcgu.o" "-o" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.exe" "D:\\Documents\\rust_manual\\target\\debug\\deps\\rust_manual-e02c4017dbb04ce1.1n
9qmwpghqvw10ei.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "D:\\Documents\\rust_manual\\target\\debug\\deps" "-L" "D:\\Programs\\Rust\\Cargo\\registry\\src\\github.com-1ecc6299db9ec823\\winapi-x86_64-pc-windows-gnu-0.4.0\\lib"
"-L" "D:\\Documents\\rust_manual\\target\\debug\\build\\libssh2-sys-611fa0ef83ad9897\\out\\build" "-L" "D:\\Documents\\rust_manual\\target\\debug\\build\\libz-sys-0bd5febd50380866\\out\\build" "-L" "D:\\Programs\\Rust\\Rustup\\tool
chains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "D:\\Documents\\rust_manual\\target\\debug\\deps\\liblinked_hash_map-8ccaf07e1678ba81.rlib" "D:\\Documents\\rust_manual\\target\\debug\\d
eps\\libfs2-7cdf4dce3545590b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libaes_gcm_siv-7f08f4ec229f0194.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libaes-9e69959843670351.rlib" "D:\\Documents\\rust_manual\\
target\\debug\\deps\\libaes_soft-85e91b74f1d42369.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libbyteorder-59f20df4b329d08b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libopaque_debug-77ca4cb51d8100fa.rlib" "
D:\\Documents\\rust_manual\\target\\debug\\deps\\libzeroize-bab8662dce816576.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libpolyval-0f2876d6fb299760.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libuniversal_ha
sh-295cab4c7b6658eb.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libsubtle-19f12b0836f68a71.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libaead-ef3c7269241d4b63.rlib" "D:\\Documents\\rust_manual\\target\\debug
\\deps\\libblock_cipher-662444e0b79f5644.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libgeneric_array-8edaebd677632f76.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libtypenum-1251f48f890b7d62.rlib" "D:\\Docume
nts\\rust_manual\\target\\debug\\deps\\libserde_json-53f81e6916eb8e26.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libryu-c8e41e31d4a509cb.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libitoa-903fb6c5622b5617.r
lib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libserde-4d09c2dcdbb1d8b3.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libssh2-7df6425f87af870e.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libparking_lot
-07aaede0978bcf2e.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libparking_lot_core-476c2f592babd25d.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libsmallvec-5b2a8d31eb1a4c6d.rlib" "D:\\Documents\\rust_manual\\t
arget\\debug\\deps\\liblock_api-7a323e635f8733ad.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libscopeguard-6c6d401b1f6f82b5.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib" "D
:\\Documents\\rust_manual\\target\\debug\\deps\\liblibz_sys-5c6fdfaf87470695.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\librand-952ff6682f89685d.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\librand_chacha-061
9462aab8ab8cf.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libppv_lite86-dc7a8f001990536b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\librand_core-29c3a2129db92df7.rlib" "D:\\Documents\\rust_manual\\target\\de
bug\\deps\\libgetrandom-60ce90fab31a9998.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libnotify-a3f8496c1768c614.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libwalkdir-01728b165c663904.rlib" "D:\\Documents\\ru
st_manual\\target\\debug\\deps\\libsame_file-bade0aa981bdf286.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libwinapi_util-aa42252baaa29f06.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibc-408386b57fa89aa8.r
lib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libfiletime-85a1a02ff2eb4f83.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libwinapi-fc941a2b370d489b.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libcfg_if
-cf58d0d3cd0e6fed.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libbitflags-288950b807dfd7f7.rlib" "D:\\Documents\\rust_manual\\target\\debug\\deps\\libbase64-e64b24a18f7239bc.rlib" "-Wl,--start-group" "D:\\Programs\\Rust\
\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-447f0e6919e87703.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\l
ib\\libpanic_unwind-6691a7d28fd5ead6.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-ee4714732ebaf9a3.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\
\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-e062de0dbb254b6a.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\
\lib\\libbacktrace-2bc81dc380687e4b.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libbacktrace_sys-53b5dac028b62d7c.rlib" "D:\\Programs\\Rust\\Rustup\\toolchai
ns\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-cb491f3ffc25ac52.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\li
bunwind-9499c77410f0cb84.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-cb2a1962c04b6646.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-
pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-c582a1654a681be9.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-2285fe2f7f9a72ec.rlib
" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-1a51942af531248c.rlib" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-
gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-d7ecf429ccc8dc70.rlib" "-Wl,--end-group" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-4f
c9e886634acec6.rlib" "-Wl,-Bdynamic" "-lbcrypt" "-lcrypt32" "-luser32" "-lntdll" "-ladvapi32" "-lwinapi_advapi32" "-lwinapi_cfgmgr32" "-lwinapi_fwpuclnt" "-lwinapi_gdi32" "-lwinapi_kernel32" "-lwinapi_msimg32" "-lwinapi_ntdll" "-lwi
napi_opengl32" "-lwinapi_synchronization" "-lwinapi_user32" "-lwinapi_winspool" "-lwinapi_ws2_32" "-ladvapi32" "-lws2_32" "-luserenv" "-lmingwex" "-lmingw32" "-lmsvcrt" "-lmsvcrt" "-luser32" "-lkernel32" "-lgcc_eh" "-l:libpthread.a"
"-lgcc" "-lmsvcrt" "-lkernel32" "D:\\Programs\\Rust\\Rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
= note: /usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(channel.o): in function `_libssh2_channel_free':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/channel.c:2723: undefined reference to `__assert_func'
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/channel.c:2723:(.text$_libssh2_channel_free+0x3a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol
`__assert_func'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(sftp.o): in function `sftp_init':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:790: undefined reference to `__assert_func'
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:790:(.text$sftp_init+0x48): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__assert_func'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(sftp.o): in function `sftp_read':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:1459: undefined reference to `__assert_func'
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:1459:(.text$sftp_read+0x23a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__assert_fun
c'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:1460: undefined reference to `__assert
_func'
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:1460:(.text$sftp_read+0x26c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__assert_fun
c'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: /cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:1720: undefined reference to `__assert
_func'
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:1720:(.text$sftp_read+0x968): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__assert_fun
c'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(sftp.o):/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com
-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:2648: more undefined references to `__assert_func' follow
D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(sftp.o): in function `sftp_close_handle':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/sftp.c:2648:(.text$sftp_close_handle+0x305): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__as
sert_func'
D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(transport.o): in function `decrypt':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/transport.c:139:(.text$decrypt+0x63): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__assert_fu
nc'
D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(transport.o): in function `_libssh2_transport_read':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/transport.c:349:(.text$_libssh2_transport_read+0x13c): relocation truncated to fit: R_X86_64_PC32 against undefined sy
mbol `__assert_func'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(userauth.o): in function `memory_read_publickey':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/userauth.c:511: undefined reference to `__locale_ctype_ptr'
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/userauth.c:511:(.text$memory_read_publickey+0xaa): relocation truncated to fit: R_X86_64_PC32 against undefined symbol
`__locale_ctype_ptr'
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: D:\\Documents\\rust_manual\\target\\debug\\deps\\liblibssh2_sys-b34136eee9b6d61b.rlib(userauth.o): in function `file_read_publickey':
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/userauth.c:613: undefined reference to `__locale_ctype_ptr'
/cygdrive/d/Programs/Rust/Cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.2.18/libssh2/src/userauth.c:613:(.text$file_read_publickey+0x1a5): relocation truncated to fit: R_X86_64_PC32 against undefined symbol
`__locale_ctype_ptr'
collect2: error: ld returned 1 exit status
error: aborting due to previous error; 80 warnings emitted
error: could not compile `rust_manual`.
Caused by:
process didn't exit successfully: `rustc --crate-name rust_manual --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=e02c4017dbb04ce1 -C
extra-filename=-e02c4017dbb04ce1 --out-dir D:\Documents\rust_manual\target\debug\deps -C linker=D:\Programs\Cygwin\bin\gcc.exe -C incremental=D:\Documents\rust_manual\target\debug\incremental -L dependency=D:\Documents\rust_manual\t
arget\debug\deps --extern aes_gcm=D:\Documents\rust_manual\target\debug\deps\libaes_gcm-46686bd39b60c02f.rlib --extern aes_gcm_siv=D:\Documents\rust_manual\target\debug\deps\libaes_gcm_siv-7f08f4ec229f0194.rlib --extern base64=D:\Do
cuments\rust_manual\target\debug\deps\libbase64-e64b24a18f7239bc.rlib --extern fs2=D:\Documents\rust_manual\target\debug\deps\libfs2-7cdf4dce3545590b.rlib --extern linked_hash_map=D:\Documents\rust_manual\target\debug\deps\liblinked
_hash_map-8ccaf07e1678ba81.rlib --extern notify=D:\Documents\rust_manual\target\debug\deps\libnotify-a3f8496c1768c614.rlib --extern rand=D:\Documents\rust_manual\target\debug\deps\librand-952ff6682f89685d.rlib --extern rand_core=D:\
Documents\rust_manual\target\debug\deps\librand_core-29c3a2129db92df7.rlib --extern serde=D:\Documents\rust_manual\target\debug\deps\libserde-4d09c2dcdbb1d8b3.rlib --extern serde_json=D:\Documents\rust_manual\target\debug\deps\libse
rde_json-53f81e6916eb8e26.rlib --extern ssh2=D:\Documents\rust_manual\target\debug\deps\libssh2-7df6425f87af870e.rlib -L native=D:\Programs\Rust\Cargo\registry\src\github.com-1ecc6299db9ec823\winapi-x86_64-pc-windows-gnu-0.4.0\lib -
L native=D:\Documents\rust_manual\target\debug\build\libssh2-sys-611fa0ef83ad9897\out\build -L native=D:\Documents\rust_manual\target\debug\build\libz-sys-0bd5febd50380866\out\build` (exit code: 1)
The output indicates to me that Rust is not linking the correct files. However, I have no idea how to solve this. I tried searching the web for similar problems, but couldn't find any that matched mine. If I missed something though, feel free to point me in the right direction.
Disclaimers:
The main goal of this question is to get debugging with JetBrains CLion working. Thus, alternative ways for achieving this outside my current attempts are also welcome.
I am new to Rust, and have limited knowledge of C/C++ compilers and linkers.
I'm trying to make a Rust program that statically links against libusb, using the MSVC toolchain, but it blows up at run-time from a missing DLL:
error: process didn't exit successfully: `target\debug\test_libusb.exe` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)
I used Dependency Walker to find that the missing DLL is LIBUSB-1.0.DLL. Adding it to the project solves the problem and so does dynamically linking everything, but I would like to avoid this solution.
My starting point was this libusb-sys crate, but since it didn't work I made a simpler similar crate. I got libusb from vcpkg.
libusb-sys/src/lib.rs
extern crate libc;
use libc::c_char;
#[repr(C)]
pub struct libusb_version {
pub major: u16,
pub minor: u16,
pub micro: u16,
pub nano: u16,
pub rc: *const c_char,
pub describe: *const c_char,
}
#[link(name = "libusb-1.0", kind = "static")]
extern "C" {
pub fn libusb_get_version() -> *const libusb_version;
}
libusb-sys/Cargo.toml
[package]
name = "libusb-sys"
version = "0.1.0"
build = "build.rs"
link = "libusb-1.0"
[dependencies]
libc = "0.2"
libusb-sys/build.rs
fn main() {
println!("
cargo:rustc-link-lib=static=libusb-1.0
cargo:rustc-link-search=native=C:/vcpkg/packages/libusb_x64-windows/lib")
}
Then I used this on my program's crate:
test_libusb/src/main.rs
extern crate libusb_sys as ffi;
fn main() {
unsafe {
let version = ffi::libusb_get_version();
println!(
"libusb v{}.{}.{}.{}",
(*version).major,
(*version).minor,
(*version).micro,
(*version).nano
);
}
}
test_libusb/Cargo.toml
[package]
name = "test_libusb"
version = "0.1.0"
[dependencies]
"libusb-sys" = { path = "../libusb-sys" }
Here's the entire compiler output, in case it's helpful:
G:\programming\rust\test_libusb> cargo run --verbose
Compiling libc v0.2.58
Compiling libusb-sys v0.1.0 (G:\programming\rust\libusb-sys)
Running `rustc --crate-name build_script_build C:\Users\slysherz\.cargo\registry\src\github.com-1ecc6299db9ec823\libc-0.2.58\build.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg "feature=\"default\"" --cfg "feature=\"std\"" -C metadata=f83941a94611be11 -C extra-filename=-f83941a94611be11 --out-dir G:\programming\rust\test_libusb\target\debug\build\libc-f83941a94611be11 -L dependency=G:\programming\rust\test_libusb\target\debug\deps --cap-lints allow`
Running `rustc --crate-name build_script_build G:\programming\rust\libusb-sys\build.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=71e53c2aee584c72 -C extra-filename=-71e53c2aee584c72 --out-dir G:\programming\rust\test_libusb\target\debug\build\libusb-sys-71e53c2aee584c72 -C incremental=G:\programming\rust\test_libusb\target\debug\incremental -L dependency=G:\programming\rust\test_libusb\target\debug\deps`
Running `G:\programming\rust\test_libusb\target\debug\build\libusb-sys-71e53c2aee584c72\build-script-build`
Running `G:\programming\rust\test_libusb\target\debug\build\libc-f83941a94611be11\build-script-build`
Running `rustc --crate-name libc C:\Users\slysherz\.cargo\registry\src\github.com-1ecc6299db9ec823\libc-0.2.58\src\lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg "feature=\"default\"" --cfg "feature=\"std\"" -C metadata=b67580e06366e753 -C extra-filename=-b67580e06366e753 --out-dir G:\programming\rust\test_libusb\target\debug\deps -L dependency=G:\programming\rust\test_libusb\target\debug\deps --cap-lints allow --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_core_cvoid --cfg libc_packedN`
Running `rustc --crate-name libusb_sys G:\programming\rust\libusb-sys\src\lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=94e8ef72b03c18f5 -C extra-filename=-94e8ef72b03c18f5 --out-dir G:\programming\rust\test_libusb\target\debug\deps -C incremental=G:\programming\rust\test_libusb\target\debug\incremental -L dependency=G:\programming\rust\test_libusb\target\debug\deps --extern libc=G:\programming\rust\test_libusb\target\debug\deps\liblibc-b67580e06366e753.rlib -L native=C:/vcpkg/packages/libusb_x64-windows/lib -l static=libusb-1.0`
Compiling test_libusb v0.1.0 (G:\programming\rust\test_libusb)
Running `rustc --crate-name test_libusb src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=8f2bb1a8f56e2223 -C extra-filename=-8f2bb1a8f56e2223 --out-dir G:\programming\rust\test_libusb\target\debug\deps -C incremental=G:\programming\rust\test_libusb\target\debug\incremental -L dependency=G:\programming\rust\test_libusb\target\debug\deps --extern libusb_sys=G:\programming\rust\test_libusb\target\debug\deps\liblibusb_sys-94e8ef72b03c18f5.rlib -L native=C:/vcpkg/packages/libusb_x64-windows/lib`
Finished dev [unoptimized + debuginfo] target(s) in 1.20s
Running `target\debug\test_libusb.exe`
error: process didn't exit successfully: `target\debug\test_libusb.exe` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND)
Even after compiling libusb from scratch with VS 2017 I still get a link error:
= note: test_libusb-528eb6acc7e5c681.3w5rrhap2r2yw5if.rcgu.o : error LNK2019: unresolved external symbol libusb_get_version referenced in function _ZN11test_libusb4main17hcb0c36db62706c3bE
G:\programming\rust\test_libusb\target\debug\deps\test_libusb-528eb6acc7e5c681.exe : fatal error LNK1120: 1 unresolved externals
When I call this function directly from the first crate it works though.
I've started to learn Rust recently, so I'm not sure about how any of this works. Why does Rust try to load a DLL in this situation?
#Shepmaster was right, the libusb:x64-windows triplet for vcpkg only contains definitions that try to call the real functions from the DLL.
I tried to load this library from a simple C program and I got the exact same error:
test.c
#include "C:\vcpkg\installed\x64-windows\include\libusb-1.0\libusb.h"
int main()
{
const struct libusb_version *version = libusb_get_version();
printf("Version %d.%d.%d", version->major, version->minor, version->micro);
}
compiled with:
cl test.c /link C:\vcpkg\installed\x64-windows\lib\libusb-1.0.lib
results in the same missing DLL error. But if I do with with the different libusb:x64-windows-static triplet:
test.c
#pragma comment(lib, "Advapi32.lib")
#include "C:\vcpkg\installed\x64-windows-static\include\libusb-1.0\libusb.h"
int main()
{
const struct libusb_version *version = libusb_get_version();
printf("Version %d.%d.%d", version->major, version->minor, version->micro);
}
compiled with:
cl test.c /link C:\vcpkg\installed\x64-windows-static\lib\libusb-1.0.lib
works just fine:
>test.exe
Version 1.0.22
To sum it up, if you want to statically link a Rust program against libusb, download vspkg and install
vcpkg.exe install libusb:x64-windows-static.
Set an environment variable LIBUSB_DIR that points to C:\vcpkg\installed\x64-windows-static and use the patched version of libusb-sys by putting this in your
Cargo.toml:
[dependencies]
libusb = "0.3"
libusb-sys = "0.2.3"
[patch.crates-io]
"libusb-sys" = { git = "https://github.com/cmsd2/libusb-sys" }
TL:DR - What is the correct invocation within a Build.gn file to properly link Chromium to a third party Mac OS X Framework (and additionally include it in the Contents/Frameworks/ app bundle path)?
See below for my Build.gn and path setups.
I am customizing a Chrome browser by adding support for video capture via a 3rd party library. Ive modified existing Build.gn files to find my third party deps and compile my new source. Ive modified an existing Chromium Build.gn to include my new dependency:
media/capture/video/mac/DEPS:
include_rules = [
"+third_party/decklink",
"+third_party/Syphon",
]
Which correctly finds my new Build.gn for my Framework, Syphon:
My Build.gn is below:
if (is_mac) {
loadable_module("Syphon") {
lib_dirs = ["//third_party/Syphon/mac/"]
libs = ["Syphon.framework"]
}
Compilation works, but building fails if I attempt to use objects from the Framework I'm including. I'm used to these linking errors on OS X / Xcode, but with Ninja/GN I'm unclear on the correct way to resolve them.
The output of Ninja:
Note - The resulting linker arguments has a linker flag to properly use -L /path/to/third_party/Syphon/mac/ which holds Syphon.framework, however, the -framework command does not find Syphon.
I've attempted to use different Build.gn commands (like ldflags) but all result in the same issue.
Thank you.
ninja -C out/Default
ninja: Entering directory `out/Default'
[4/5095] SOLINK libcapture.dylib libcapture.dylib.TOC
FAILED: libcapture.dylib libcapture.dylib.TOC
if [ ! -e "./libcapture.dylib" -o ! -e "./libcapture.dylib.TOC" ] || otool -l "./libcapture.dylib" | grep -q LC_REEXPORT_DYLIB ; then TOOL_VERSION=1484604693 ../../build/toolchain/mac/linker_driver.py ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-install_name,#rpath/"libcapture.dylib" -stdlib=libc++ -arch x86_64 -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -Wl,-ObjC -Wl,-rpath,#loader_path/. -Wl,-rpath,#loader_path/../../.. -o "./libcapture.dylib" -Wl,-filelist,"./libcapture.dylib.rsp" -framework AVFoundation -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework Foundation -framework IOKit ./libbase.dylib ./libbase_i18n.dylib ./libmedia.dylib ./libskia.dylib ./libdisplay.dylib ./libgfx.dylib ./libicui18n.dylib ./libicuuc.dylib ./libshared_memory_support.dylib ./libbindings.dylib ./libmojo_public_system_cpp.dylib ./libmojo_public_system.dylib ./libdisplay_types.dylib ./libgeometry.dylib ./librange.dylib && { otool -l "./libcapture.dylib" | grep LC_ID_DYLIB -A 5; nm -gP "./libcapture.dylib" | cut -f1-2 -d' ' | grep -v U$$; true; } > "./libcapture.dylib.TOC"; else TOOL_VERSION=1484604693 ../../build/toolchain/mac/linker_driver.py ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-install_name,#rpath/"libcapture.dylib" -stdlib=libc++ -arch x86_64 -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -Wl,-ObjC -Wl,-rpath,#loader_path/. -Wl,-rpath,#loader_path/../../.. -o "./libcapture.dylib" -Wl,-filelist,"./libcapture.dylib.rsp" -framework AVFoundation -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework Foundation -framework IOKit ./libbase.dylib ./libbase_i18n.dylib ./libmedia.dylib ./libskia.dylib ./libdisplay.dylib ./libgfx.dylib ./libicui18n.dylib ./libicuuc.dylib ./libshared_memory_support.dylib ./libbindings.dylib ./libmojo_public_system_cpp.dylib ./libmojo_public_system.dylib ./libdisplay_types.dylib ./libgeometry.dylib ./librange.dylib && { otool -l "./libcapture.dylib" | grep LC_ID_DYLIB -A 5; nm -gP "./libcapture.dylib" | cut -f1-2 -d' ' | grep -v U$$; true; } > "./libcapture.dylib.tmp" && if ! cmp -s "./libcapture.dylib.tmp" "./libcapture.dylib.TOC"; then mv "./libcapture.dylib.tmp" "./libcapture.dylib.TOC" ; fi; fi
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_SyphonServerDirectory", referenced from:
objc-class-ref in video_capture_device_syphon_mac.o
"_SyphonServerDescriptionAppNameKey", referenced from: media::VideoCaptureDeviceSyphonMac::EnumerateDevices(std::__1::vector<media::VideoCaptureDeviceDescriptor, std::__1::allocator<media::VideoCaptureDeviceDescriptor> >*) in video_capture_device_syphon_mac.o "_SyphonServerDescriptionNameKey", referenced from:media::VideoCaptureDeviceSyphonMac::EnumerateDevices(std::__1::vector<media::VideoCaptureDeviceDescriptor, std::__1::allocator<media::VideoCaptureDeviceDescriptor> >*) in video_capture_device_syphon_mac.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):
File "../../build/toolchain/mac/linker_driver.py", line 229, in <module>
Main(sys.argv)
File "../../build/toolchain/mac/linker_driver.py", line 79, in Main
subprocess.check_call(compiler_driver_args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['../../third_party/llvm-build/Release+Asserts/bin/clang++', '-shared', '-Wl,-install_name,#rpath/libcapture.dylib', '-stdlib=libc++', '-arch', 'x86_64', '-Werror', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk', '-mmacosx-version-min=10.9', '-Wl,-ObjC', '-Wl,-rpath,#loader_path/.', '-Wl,-rpath,#loader_path/../../..', '-o', './libcapture.dylib', '-Wl,-filelist,./libcapture.dylib.rsp', '-framework', 'AVFoundation', '-framework', 'CoreFoundation', '-framework', 'CoreGraphics', '-framework', 'CoreMedia', '-framework', 'CoreVideo', '-framework', 'Foundation', '-framework', 'IOKit', './libbase.dylib', './libbase_i18n.dylib', './libmedia.dylib', './libskia.dylib', './libdisplay.dylib', './libgfx.dylib', './libicui18n.dylib', './libicuuc.dylib', './libshared_memory_support.dylib', './libbindings.dylib', './libmojo_public_system_cpp.dylib', './libmojo_public_system.dylib', './libdisplay_types.dylib', './libgeometry.dylib', './librange.dylib']' returned non-zero exit status 1
[13/5095] CXX obj/third_party/WebKit/Source/wtf/wtf_unittests/ListHashSetTest.o
ninja: build stopped: subcommand failed.
ldflags was the trick, passing -F to update Framework search paths, (not library paths with -L or lib_dirs commands)
if (is_mac) {
loadable_module("Syphon") {
ldflags = ["-F"+"../../third_party/Syphon/mac/"]
libs = ["Syphon.framework"]
}