Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't be build with msvc #17

Open
bitbegin opened this issue May 7, 2017 · 15 comments
Open

can't be build with msvc #17

bitbegin opened this issue May 7, 2017 · 15 comments

Comments

@bitbegin
Copy link

bitbegin commented May 7, 2017

rust msvc environment can't use pkg-config-sys crate. Is there any solutions?

@Boscop
Copy link

Boscop commented Nov 3, 2017

I got it working on windows with a .cargo/config build script override and the dll from here:
https://sourceforge.net/projects/libusb/files/

[target.x86_64-pc-windows-msvc.'usb-1.0']
rustc-link-search = ['D:\libs\64bit']
rustc-link-lib = ['libusb-1.0']

@dcuddeback
Copy link
Owner

@bitbegin I only have experience building with MinGW on Windows. I don't recall whether MSVC was even an option for Rust at the time (that was nearly 3 years ago). Earlier this year, someone opened a PR for libusb-sys with a build strategy that he claims supports MSVC: dcuddeback/libusb-sys#5. I haven't had time to test it myself, and since I'm not as familiar with Windows as I am with Unix, I could use help testing it. If you get a chance to test dcuddeback/libusb-sys#5, I'd appreciate some feedback on whether or not it solves your issue.

@Boscop Thanks for the work-around.

@Geobert
Copy link

Geobert commented Apr 25, 2018

I managed to test the PR and it works after doing:

  • Get libusb from http://libusb.info/
  • create a libusb folder somewhere
  • inside, create a lib and an include folder
  • put a static version libusb-1.0.lib inside lib (I put MS64 version)
  • put libusb.h inside include
  • set up an environment var LIBUSB_DIR that point to your libusb folder

To merge the PR I just edited build.rs from .cargo\registry\src\github.com-1ecc6299db9ec823\libusb-sys-0.2.3\ and removed the target dir from my project, then build again.

@Geobert
Copy link

Geobert commented Apr 25, 2018

I talk too fast, cargo check passes, but not cargo build after putting the example code. Linking is failing with:

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.16u6js6g0l3k1ic6.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1e7x6bh60ymc36tc.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1im38lueib99jsk0.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1jnlhyxj59jycbjv.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1mvmz58owquyropc.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1o6b1la7g4jnv39b.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1q8ffos2d96smbjs.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1y16o1qfye96o7m0.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1zeawhkbeobww1zn.rcgu.o"
"C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.1zwd8n7bcl3vhvvh.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.200sjsykd511hpmp.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.236iz806sghm3wx.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.23tqyymcb18u96mb.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2f0hry2t7c05ttdi.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2jqywn86b2gsqohu.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2kjrmm4fe2aha78f.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2lb322s8654e4il9.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2lp1515u5se0tpuf.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2lyh15q6cjwzy18c.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2r82puffnvvb8iic.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2uba1xvp3aakqmtj.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2ujx3sbmswjw52yh.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2uly7i8jy3oqnru3.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.2w6xsa2hbi53xhak.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3171x0bwu82dptu7.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3ayaeypdcro9d6yk.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3cx7oljifvb206q7.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3do2u7erct6u2z3t.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3g94tobrpgum5dk6.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3kfx4ynvkmi2y9i5.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3ldk0i2zxftngav8.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3oqznv5oym7l3m4e.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.3rngp6bm2u2q5z0y.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.436dotimmrgzkwfa.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.43v6g0y2xsxoggnt.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.45nf4z58qqykpcpi.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.45pc7c65foh9i35f.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.48721dc4k5qxei0u.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.49a7n47po4ttqjl7.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.49lx1q7cxvpykyv0.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4brwxiorhmgsb6oc.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4ezmh1vbs95c5ack.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4g47d2sx6m33abop.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4jdnq7xfjeka1bt.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4m0frhmbd81kgg1i.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4rknevt5yo7mh62p.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4x5aex27gziosnqw.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4xq48u46a1pwiqn7.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4xuhwz5yy6q4gvgg.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4ybye971cqflgun6.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4yh8x2b62dcih00t.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.4ypvbwho0bu5tnww.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.51s1w397y42gpez1.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.54zq6xwdlu4umqga.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.5544xgl7axh7p8nz.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.555x2l3tz3it37mb.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.5beqqbexwb143v6a.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.63mmpc50mjcb0lb.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.6oziy6ef8n0ff51.rcgu.o"
"C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.8xzrsc1ux72v29j.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.98g0d9x8aw3akpe.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.9elsx31vb4it187.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.9fcb3syd3ne5k0n.rcgu.o"
"C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.c6lbtaiefvx3wya.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.e19kx9t7xhzajfl.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.kt25z0521ngsjub.rcgu.o" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.uc93mja68u2kt7i.rcgu.o"
"/OUT:C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.exe" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\rscom-7d742b1c5f8b0a11.crate.allocator.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\lib\\lib" "/LIBPATH:C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libserde-b73ddffedf3a7c7c.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\liblibusb-13098138a50689d9.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\liblibusb_sys-ee89fd8eca350f85.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\liblibc-dce9ac9e5a7dae71.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libbit_set-357b81c3b62dac9c.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libbit_vec-f7cdbf31062fc837.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libhex-b9675f85e5a7cc62.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libstructopt-976c8677afc80cce.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libclap-7f33ec539fd9748d.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libvec_map-ca435936dc3a3681.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libtextwrap-a09b36c948d70492.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libunicode_width-04141553a42b3e37.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libstrsim-f65eec109d6db413.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libbitflags-26328f177ad318e4.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libatty-9d53e3caa7759402.rlib" "C:\\Users\\Geobomatic\\Documents\\Perso\\rscom\\target\\debug\\deps\\libwinapi-1fcb844c9dfff517.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-1cce2a9d20ab1f24.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-65a4af75723cdd90.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-2e8655cc7305d65c.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-46a305d94fa2d1ac.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-af1f1cda65a920c9.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-46dfcbf8c4dcea26.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_unicode-239f9a431f378980.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-b754d68cb5d0aae4.rlib" "C:\\Users\\Geobomatic\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-2cbf590829e54572.rlib" "advapi32.lib" "opengl32.lib" "setupapi.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "user32.lib" "winspool.lib" "dbghelp.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: liblibusb_sys-ee89fd8eca350f85.rlib(core.obj) : error LNK2019: unresolved external symbol __imp__vsnprintf referenced in function usbi_vsnprintf
          liblibusb_sys-ee89fd8eca350f85.rlib(core.obj) : error LNK2001: unresolved external symbol __imp__iob
          liblibusb_sys-ee89fd8eca350f85.rlib(windows_nt_common.obj) : error LNK2019: unresolved external symbol __imp_sprintf referenced in function windows_error_str
          liblibusb_sys-ee89fd8eca350f85.rlib(windows_winusb.obj) : error LNK2001: unresolved external symbol __imp_sprintf
          liblibusb_sys-ee89fd8eca350f85.rlib(windows_winusb.obj) : error LNK2019: unresolved external symbol __imp_sscanf referenced in function enumerate_hcd_root_hub
          C:\Users\Geobomatic\Documents\Perso\rscom\target\debug\deps\rscom-7d742b1c5f8b0a11.exe : fatal error LNK1120: 4 unresolved externals

@Geobert
Copy link

Geobert commented Apr 25, 2018

From what I can gather, we may need legacy_stdio_definitions.lib
How de we pass this kind of information in Rust?

@Geobert
Copy link

Geobert commented Apr 25, 2018

As a test, I've put legacy_stdio_definitions.lib in the libusb/lib folder and added println!("cargo:rustc-link-lib=static=legacy_stdio_definitions"); to the build.rs and I got rid of some unresolved symbols and have only one left: 

  = note: liblibusb_sys-ee89fd8eca350f85.rlib(core.obj) : error LNK2001: unresolved external symbol __imp__iob
          I:\Dev\rscom\target\debug\deps\rscom-accb7ee3ebb9b347.exe : fatal error LNK1120: 1 unresolved externals

@Geobert
Copy link

Geobert commented Apr 26, 2018

Ok, I've done more tries and here are my results.
Using the binary provided by libusb.info, I got the link errors above. These errors seems to happen because of different CRT use during compilation.
So I've taken the source of libusb and compile it using VS2015 (my toolchain is using 2015). I put this freshly compile static libusb-1.0.lib into the $LIBUSB_DIR/lib and build again my Rust example. With this lib, I got different link errors:

  = note: liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb9.rcgu.o) : error LNK2019: unresolved external symbol libusb_exit referenced in function _ZN66_$LT$libusb..context..Context$u20$as$u20$core..ops..drop..Drop$GT$4drop17h92ba0b1597e4d4abE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb9.rcgu.o) : error LNK2019: unresolved external symbol libusb_init referenced in function _ZN6libusb7context7Context3new17hf1d62ac4c11a84ebE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb9.rcgu.o) : error LNK2019: unresolved external symbol libusb_set_debug referenced in function _ZN6libusb7context7Context13set_log_level17hd27a1619b20a0b27E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb9.rcgu.o) : error LNK2019: unresolved external symbol libusb_has_capability referenced in function _ZN6libusb7context7Context14has_capability17he3d08c214943b991E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb9.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_device_list referenced in function _ZN6libusb7context7Context7devices17hfdb41a2c57b697e1E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb9.rcgu.o) : error LNK2019: unresolved external symbol libusb_open_device_with_vid_pid referenced in function _ZN6libusb7context7Context24open_device_with_vid_pid17h451f5dd19851b80cE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_unref_device referenced in function _ZN78_$LT$libusb..device..Device$LT$$u27$a$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h6cb3f3281a0f4f70E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_device_descriptor referenced in function _ZN6libusb6device6Device17device_descriptor17ha358db15fe92e5deE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_config_descriptor referenced in function _ZN6libusb6device6Device17config_descriptor17hd862df130da388b8E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_active_config_descriptor referenced in function _ZN6libusb6device6Device24active_config_descriptor17hcc26b087f16a1309E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_bus_number referenced in function _ZN6libusb6device6Device10bus_number17h645a99088b77cb5bE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_device_address referenced in function _ZN6libusb6device6Device7address17h6d459b97f06d0034E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_device_speed referenced in function _ZN6libusb6device6Device5speed17hc5bcb40e0c405490E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_open referenced in function _ZN6libusb6device6Device4open17h485d0c08e5f60568E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb15.rcgu.o) : error LNK2019: unresolved external symbol libusb_ref_device referenced in function _ZN6libusb6device11from_libusb17h0272511ee7ea1a65E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb5.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_version referenced in function _ZN6libusb7version7version17hac8d6b6cd35481e8E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb5.rcgu.o) : error LNK2019: unresolved external symbol libusb_free_device_list referenced in function _ZN87_$LT$libusb..device_list..DeviceList$LT$$u27$a$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h9a55496045f9a381E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_close referenced in function _ZN91_$LT$libusb..device_handle..DeviceHandle$LT$$u27$a$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h5408c1ae06be6a55E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_release_interface referenced in function _ZN91_$LT$libusb..device_handle..DeviceHandle$LT$$u27$a$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h5408c1ae06be6a55E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_get_configuration referenced in function _ZN6libusb13device_handle12DeviceHandle20active_configuration17h15938f8a7d6d54c9E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_set_configuration referenced in function _ZN6libusb13device_handle12DeviceHandle24set_active_configuration17h123d38aa5d3f4409E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_reset_device referenced in function _ZN6libusb13device_handle12DeviceHandle5reset17hd5192633c9f6b148E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_kernel_driver_active referenced in function _ZN6libusb13device_handle12DeviceHandle20kernel_driver_active17hdf9c519fcbda344dE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_detach_kernel_driver referenced in function _ZN6libusb13device_handle12DeviceHandle20detach_kernel_driver17h2210b8438776ebcfE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_attach_kernel_driver referenced in function _ZN6libusb13device_handle12DeviceHandle20attach_kernel_driver17h14424713035562bdE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_claim_interface referenced in function _ZN6libusb13device_handle12DeviceHandle15claim_interface17h96e3fe779477c873E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_set_interface_alt_setting referenced in function _ZN6libusb13device_handle12DeviceHandle21set_alternate_setting17h9cdfc4f15c041215E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_interrupt_transfer referenced in function _ZN6libusb13device_handle12DeviceHandle14read_interrupt17h24681a588242d8aeE
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_bulk_transfer referenced in function _ZN6libusb13device_handle12DeviceHandle9read_bulk17hcd98b13a86f6a3d7E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb1.rcgu.o) : error LNK2019: unresolved external symbol libusb_control_transfer referenced in function _ZN6libusb13device_handle12DeviceHandle12read_control17ha5f0d46f4a927dd7E
          liblibusb-13098138a50689d9.rlib(libusb-13098138a50689d9.libusb14.rcgu.o) : error LNK2019: unresolved external symbol libusb_free_config_descriptor referenced in function _ZN85_$LT$libusb..config_descriptor..ConfigDescriptor$u20$as$u20$core..ops..drop..Drop$GT$4drop17hf7ad6b969b64f277E
          C:\Users\Geobomatic\Documents\Perso\rscom\target\debug\deps\rscom-7d742b1c5f8b0a11.exe : fatal error LNK1120: 31 unresolved externals

I'm not a linker specialist and I am quite lost now :-/

@Geobert
Copy link

Geobert commented Apr 26, 2018

I'm dumb: while rebuilding libusb, I forgot to set it to x64…
So we have to rebuild libusb ourself in order to use it with VS2015 toolchain

In conclusion, the PR works if we have the correct libusb binary :)

@theronic
Copy link

@Geobert what arguments did you pass to cargo to get it use your libusb libraries?

@Geobert
Copy link

Geobert commented Feb 11, 2019

If I recall properly, I hacked into the .cargo folder to see if something can come out and I don't use libusb anymore so I didn't reach the phase to do a clean build with passing params to cargo.

Sorry :(

@theronic
Copy link

@Geobert did you switch to something else instead? I'm having a hell of a time getting it to compile for MIPS architecture.

@Geobert
Copy link

Geobert commented Feb 14, 2019

I'm using hidapi

@AJAnderson
Copy link

@Geobert sorry to necro you again. I've tried to rebuild libusb using my current build tools (2019) set to x64 but I still end up with the link errors in your earlier post (#17 (comment))

Did you do anything else after rebuilding for x64?

@Geobert
Copy link

Geobert commented Jun 6, 2019

As I said, I've done an ugly hack by tampering the files in .cargo but I can't remember what as I didn't use libusb in the end. Sorry :-/

@seanybaggins
Copy link

seanybaggins commented Jan 31, 2023

I'm not building for mvc but I managed to get my build for android using the following.

.cargo/config

[target.aarch64-linux-android]
linker = "aarch64-linux-android21-clang++"
rustflags = ["-C", "link-arg=-v"]

[target.aarch64-linux-android.'usb-1.0']
rustc-link-search = ['libs/arm64-v8a']
rustc-link-lib = ['usb-1.0']

Directory structure

.
├── .cargo
│   └── config
├── Cargo.lock
├── Cargo.toml
├── libs
│   └── arm64-v8a
│       └── libusb-1.0.so
└── src
    ├── bin
    │   ├── android.rs
    │   └── linux.rs
    └── lib.rs

Note: rustc-link-lib = ['libusb-1.0'] was changed to rustc-link-lib = ['usb-1.0']

Hopefully that helps someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants