Stlink: [compatibility] undefined reference to `libusb_set_option'

Created on 25 Mar 2020  ·  12Comments  ·  Source: stlink-org/stlink

Hi all,

I will try to compile the project on Windows 10 with MinGW-w64 without success.
The error is:
C:/stlink/src/sg.c:972: undefined reference to 'libusb_set_option'

My environement is:

  • Windows 10
  • texane/stlink 1.6.0 => This version requires the libusb-1.0.22.7z (downloaded manually)
  • MinGW-w64 i686-8.1.0-posix-dwarf-rt_v6-rev0

Can you help me?

Complete log of the compilation: log.txt

Thank you in advance.

Ju

bucompilation bufixed dependenclibusb errocompilation generadocumention owindows staturesolved

All 12 comments

Please try the develop branch instead. I think there were some fixes related to libusb since Release v1.6.0.

The mentionned error isn't displayed but the compilation failed.

log_w_develop_latest_commit_a09ef54.txt

I want to add a remark.

The last log indicates that I have already libusb in my system.
-- Found Libusb: C:/Windows/System32/libusb-1.0.dll
Sure this version is old.

What is your opinion about this.

@purjus74 I think the problem with libusb, that you download manually.
Please remove it. Clear all builds. And try one more time.

Just to give more details:
Before to use your project, my system had already a libusb instance.
libusb_on_my_windows_10

If I let the batch mingw64-build.bat to download the libusb-1.0.22.7z, the extraction fails:

...
-- Could NOT find Libusb (missing: LIBUSB_INCLUDE_DIR)
-- downloading libusb 1.0.22

7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21

Scanning the drive for archives:
1 file, 2601 bytes (3 KiB)

Extracting archive: C:\stlink-develop\scripts\libusb-1.0.22.7z
ERROR: C:\stlink-develop\scripts\libusb-1.0.22.7z
C:\stlink-develop\scripts\libusb-1.0.22.7z
Open ERROR: Can not open the file as [7z] archive


ERRORS:
Is not archive
...

It seems that the archive is file is corrupted :(
image

@slyshykO: You are right, I did not notice at first that an external libusb library was present.

I think this behavior (error during libusb-1.0.22.7z extraction) is due to my compagny protection :(
This f*#! protection creates the wanted archive file but it contains an error html page !!!

html_page

But I'm not sure that is a problem to download before the good libusb archive and put it inside the build folder.
My first log illustrates that the mingw64-build.bat finds the archive, extracts it and uses it:

-- libusb archive already in build folder

7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21

Scanning the drive for archives:
1 file, 980895 bytes (958 KiB)

Extracting archive: C:\stlink\scripts\libusb-1.0.22.7z
--
Path = C:\stlink\scripts\libusb-1.0.22.7z
Type = 7z
Physical Size = 980895
Headers Size = 682
Method = LZMA2:23 BCJ
Solid = +
Blocks = 2

Everything is Ok

@purjus74: Does your whole compilation succeed now?
@slyshykO: I think we should add a note to the instructions on not to use external libusb packages when installing on windows, as this is not the first issue of its kind.

The problem is that windows have many options on how to install libusb, also many compilers with different ABI. That is why we should provide windows builds.

I just tried on other machine (without old libusb inside C:\Windows\System32) and it's work (with develop branch, last commit #a09ef54).
Therefore, the problem is due to other libusb version already stored and used by the others projects.

Thank you for your support and for your job ;)

Reopening this as documentation and related work remains outstanding...

Was this page helpful?
0 / 5 - 0 ratings