Hello Rust Community,
I am currently learning Rust and encountering an issue: whenever I want to compile a binary with valid dependencies, I get the Error error: Error calling dlltool 'dlltool.exe': program not found
(Im using the x86 gnu win pc toolchain on win11, but the same problem persists for the msvc one)
I already checked the post with the same name, but I have rust-mingw installed, when I run rustup component add rust-mingw
I get info: component 'rust-mingw' for target 'x86_64-pc-windows-gnu' is up to date
(I also reinstalled the stable-x86_64-pc-windows-gnu toolchain). I also have mingw64 installed in the msys64-directory. It's pretty weird since the Error started appearing recently after everything working completely fine.
I have no idea what to do...
Thanks in advance
PS: It would also be nice to know how to completely reinstall Rust, I would try that too if I don't get it to work with your advice
When running where dlltool
in the command line, it says "nothing found", when running dlltool
I get basically the same output. I looked through the PATH element, but I did not find it there. I understand that I need to add it to my PATH env var, but where do I find it? As previously mentioned, it worked before.
dlltool is part of the mingw toolchain, from the mingw-w64-binutils package, so it is usually installed from mingw. but the rust-mingw component of the -gnu toolchain should also contain its own dlltool.
if you installed the mingw's dlltool, you should be able to run it at the msys/mingw shell, however the one from the rust toolchain is not added to PATH automatically, but normally cargo should be able to find it, so your problem is quite unusual. I don't really know that's going on.
if you updated the rust toolchain recently, it could be a regression of cargo, but I don't have a windows machine to test it now.
in the mean time, you may try to work around the problem by running cargo in the mingw shell, or you may add the bin directory of mingw to your system's Path. for example, suppose your msys2 is installed at C:\msys2, then you should add C:\msys2\mingw64\bin to PATH. make sure mingw-w64-binutils is installed.
Thanks, I will try that. Does it make a difference that I have MSYS64 instead of MSYS2 installed? I also don't have a Mingw64\bin directory, only an executable. Do I need to install MSYS2? And what is the difference between MSYS2 and MSYS64?
I don't know what msys64 is, but as long as it contains the mingw toolchain, specifically, the gnu binutils package, it should be good. if you are not sure, double check there is a dlltool.exe in the bin directory.
I checked to whole directory an found a "usr/bin" dir, but there was only a file called "link.exe", no dlltool. (I also checked the whole C:\MSYS64 directory, but there was no file name containing "dlltool". I have no experience with these shells, so how do I check which components are there or install new ones?
@nerditation I fixed it by reinstalling MSYS2 und installing the ming64 toolchain (after asking an AI, which I normally don't do because of my lack of confidence in their abilities aswell as my distrust)
Extensive version for people with the same problem
I deleted my MSYS2 installation in the directory C:\msys64 (The directory name isn't msys2 - I didn't know that before...) (Of course, you need to know what you had installed before if you do this and want to use it later on)
I reinstalled MSYS2 using the installer (select "Open MSYS2 (shell)" to proceed faster)
I installed the MinGW toolchain with the command pacman -S mingw-w64-x86_64-toolchain
I added the ~\msys64\mingw64\bin directory to the PATH
It should work! (test it by running cargo check while in the directory of a project with at least one dependency (You don't need to use it in your code))
I'm still really thankful you took time to provide me with your advice! As in the extensive version, I had some misconceptions about MSYS2. In the retrospective, I would have been a able to do it with your advice if I just had taken myself the time to look up some more pieces of information about MSYS2 etc.
Have a good...day I guess
I added MinGW64/bin to the path and now it works, I still wonder why there was now Mingw64/bin directory, but now works... (I added it to the extensive solution)
In the end it's basically what you said.