stlink-org / stlink

Open source STM32 MCU programming toolset
BSD 3-Clause "New" or "Revised" License
4.46k stars 1.24k forks source link

[compatibility] undefined reference to `libusb_set_option' #896

Closed ghost closed 4 years ago

ghost commented 4 years ago

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:

Can you help me?

Complete log of the compilation: log.txt

Thank you in advance.

Ju

Nightwalker-87 commented 4 years ago

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

ghost commented 4 years ago

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

log_w_develop_latest_commit_a09ef54.txt

ghost commented 4 years ago

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.

slyshykO commented 4 years ago

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

ghost commented 4 years ago

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

Nightwalker-87 commented 4 years ago

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

ghost commented 4 years ago

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
Nightwalker-87 commented 4 years ago

@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.

slyshykO commented 4 years ago

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.

ghost commented 4 years ago

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.

ghost commented 4 years ago

Thank you for your support and for your job ;)

Nightwalker-87 commented 4 years ago

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