-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
MinGW 32-bit build requires -static-libgcc to avoid DLL migraine #1049
Comments
Ah, I see the same problem with MSYS2 with 32bit build. And yes 64bit build is not affected. So this does not only affect cross build under Linux. Same thing happened under Windows. |
It seems to me this has been there for a while. Just wondering which version you check does not cause this issue. My GCC version is pretty new under MSYS2.
|
As far as i remember i often and have always see this in 32 and or 64 bit app/lib built with mingw/gcc even with native windows built. |
What is a MinGW context? Isn't the point of MinGW that you build standalone binaries that "just works"? I admit this is not obvious for shared libraries. I find it practical to have an application and a libusb DLL and no more dependencies but see that this is a somewhat middle ground. The question remains, why is this different on 64 bit? |
by mingw context i mean a machine where some mingw got installed so the gcc std lib dll is present. yes it's strange that 64 bit one doesn't has it maybe some std library helper for 64 bit ops to come on inittial point anyway you right that it will avoid the migraine by adding static-gcc in the lib build ;) |
i did on the 1.0.25 binary package
these are helper for 64 bit division why not needed on 64 bit version |
The idea is to have DLL interchangeability between the official MinGW32/64 and Visual Studio binaries as much as possible. Therefore it is good to remove the dependencies of MinGW helpers if possible. If not possible, then we need to mention to the users. My previous tests show that our official binaries are able to be interchangeable, with my simple tests (with libusb examples and openocd binary). I will try to test the 1.0.25 binaries. When I build libftdi with MinGW32/64, I always end up with MinGW helper dependencies. So I would like to see how to remove the dependencies as well if it is possible. My question is then how to link with the static-gcc with the configure option or things like that. |
@diabolo38 It seems to me the 32bit MinGW DLL of libusb-1.0.25 Windows binary has dependancies on MinGW helpers but not the 64bit MinGW DLL.
|
Older version of MinGW32 dll binary. They have libgcj-16.dll as the dependancy if the above method using strings is correct. It seems to me they are produced by similar toolchain (likely not from MSYS 2 MinGW32 compiler used by me, or Linux cross compilers used by Tormod). However, the comments here say that using "strings" will create false positive. BTW, usually I will use Dependancy Walker but it does not seem to work under my Windows 11 laptop.
|
if you used objdump -x like i did you will see what symbols is required in the gcc dll @mcuee Your investigation on past version show that even the base dll name is toolschain dependent. |
@diabolo38 Yes I agree that it is better to link to static gcc lib at build for MinGW toolchains. |
Hmm, I can not get your result for the 64bit binary.
For 32bit DLL, you are right, it has the dependency with libgcc_s_sjlj-1.dll which is not desired.
|
@diabolo38 using your objdump method, the old version of 32bit DLLs do not seem to have an issue.
|
So the only issue seems to be with the 1.0.25 MinGW32 dll as per my testing. I am not so sure why the old version does not have such an issue, probably it is due to compiler differences. In order to be not limited by a specific MinGW toolchain, I agree it is better to link to to static gcc lib at build for MinGW toolchains. |
In the binary package I posted on SF and GitHub I had myself compiled the MinGW binaries and it is quite possible I forgot to add the -static flag (it was already quite a mess to pull together the Windows package). However, they also get built in the appveyor service, from where I got the VS builds. The previous binary packages were maybe built with a local appveyor instance, from what I can guess from the paths used. Maybe they get the wanted DLL configuration there? For our convenience it should be possible to also download the appveyor MinGW build artifacts. I am just not sure how to configure this in the common "after_build" part. If I add a path that doesn't exists for some builds (the MinGW builds are piggy-backed on the VS15 build), then the 7z command and the whole job fails. There is probably a simple solution. EDIT: After writing that, I had to try just one thing (ugly or not) and it worked :)
Anyway, it would be good if our build configuration does the right thing for us by default when building locally also. |
Yes that will be the goal. Maybe the configure script needs to be changed to link to static gcc library. |
@mcuee i used objdump 2.27 without the grep dll , you will find the symbols from the dll on the lines following the dll name itself |
FYI, I encounter the same missing (I use the official dll from libusb 1.0.25 and cross-compile my project from Linux) |
Fixes libusb#1049 Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Fixes libusb#1049 Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Currently, there is an issue with the libusb prebuilt dll. Refs #3011 <#3011> Refs libusb/#1049 <libusb/libusb#1049>
Currently, there is an issue with the libusb prebuilt dll. Refs libusb/#1049 <libusb/libusb#1049> PR #3011 <#3011>
Fixes libusb#1049 Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
I still get cmake.exe .. -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -static"
mingw32-make.exe -j16 |
If you use CMake, then you may want to look at the repo here. You also need to provide more details of what you are doing. Your issue is apparently not related to libusb. So please do not continue here but rather create a discussion here. |
Ok, pasting here just to help others which encounter it too.
Note the line |
When cross-building MinGW 32-bit (gcc 9.3 on Ubuntu 20.04) the resulting DLL depends on various gcc DLLs, so if just installing the libusb.dll the program using it will fail to execute ("libgcc_s_sjlj-1.dll was not found").
Adding the extra linker option
-static-libgcc
fixes this. However, this is not needed for 64-bit builds, so it is possible that there is a bug somewhere. This is not very new, but wasn't like this some years ago either.This would better be rechecked with a newer MinGW toolchain.
The text was updated successfully, but these errors were encountered: