You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tutorial: compile for Windows on Linux with MinGW (cross compile) #168
the compiled executable was tested on an Intel 4th gen CPU and it worked BUT accented characters do not show correctly (not a problem for english). A workaround (the problem might be with MinGW): before using main.exe on a command prompt window, execute the command chcp 65001 (UTF-8 encoding).
Tried to run it on a 3rd gen intel CPU but did not work.
Tested successfully on an i5-8300H. Failed on an old Pentium G4400.
If this works well, I suppose it would be a good idea to setup a Github Workflow to auto-compile whenever this repo is updated.
Reacted by Georgi Gerganov, Temm, Bill and channie88
@regstuff
Yes - having a Github action to build a Windows executable would be great.
I think there are a lot of people that want to try Whisper on Windows without going through the hassle of compiling it.
@regstuff Yes - having a Github action to build a Windows executable would be great. I think there are a lot of people that want to try Whisper on Windows without going through the hassle of compiling it.
I will try and report back. By the way, when browsing https://github.com/ggerganov/whisper.cpp/actions I found the item ggml : fix Windows build #225https://github.com/ggerganov/whisper.cpp/actions/runs/3509700272, and at the end of the page you can find that the "Artifacts Produced during runtime" section contains two automatically compiled windows executables (win32 and win64). I have tried the 64bit version and works ok on windows 10. I guess you already implemented the github action a couple of days ago.
Ah yes - I didn't even realise that the job already produces the executable. Not sure how to reference the latest one though - I would like to put a link the README.
I think it would be still useful to be able to cross compile using mingw, so if you get the chance to try it - let us know.
Ah yes - I didn't even realise that the job already produces the executable. Not sure how to reference the latest one though - I would like to put a link the README.
I think it would be still useful to be able to cross compile using mingw, so if you get the chance to try it - let us know.
@ggerganov I found a workaround (the problem might be with MinGW): before using main.exe on a command prompt window, execute the command chcp 65001 (UTF-8 encoding).
@Topping1 Thank you for the efforts. I just pushed the windows.h fix on master and referenced this issue from the README for building with MinGW. If you want, you can update your original comment at the top of the thread with the latest instruction, so it is more visible when someone looks for the build steps.
Then I tried main.exe again but still running into error "application did not start correctly"
@R4ZZ3 I have tried your setup (WSL2 but with ubuntu 20.04) with the instructions of the first message of this thread and could compile the file with no errors about libwinpthread-1.dll missing. Not sure what else can be happening. Maybe try to compile in a fresh install of a linux VM?
When I run main.exe,it gives me error which the system loss file named libgcc_s_seh-1.dll. And After I have put the file into exact path,there was a new problems which the application could't run (0x000007b).
For those unfamiliar, it's essential not only to compile the project inside msys2 shell (ucrt64) ,but also to use the main executable there, probably also assuming the path delimiter correction. It looks like you tried to run it outside msys2. So if you have a file c:\myfiles\mywav.wav then the command line inside ucrt64 should be
The disadvantages of using msys2, is that the binary won't run outside of that environment because it depended on msys2DLLs.
The simplest way to compile whisper.cpp on Windows, is using msvc compiler (of Microsoft)
If you still need it, let me know and I'll provide instructions
No need to trouble yourself anymore, I have successfully compiled on Linux. Thank you very much for your kind assistance.
The disadvantages of using msys2, is that the binary won't run outside of that environment because it depended on msys2DLLs. The simplest way to compile whisper.cpp on Windows, is using msvc compiler (of Microsoft)
If you still need it, let me know and I'll provide instructions
If you still need it, let me know and I'll provide instructions
@thewh1teagle, It would be great in general, preferably with command-line options and information about versions compatibility. Sometimes one can have some (ancient) msvc installed for some purpose in the past and it would be nice if some bat file with minor correction would also work with it.
The disadvantages of using msys2, is that the binary won't run outside of that environment because it depended on msys2DLLs.
@thewh1teagle, I managed to make a static linking without much change to your routine, probably some minor questions along the way.
Basically there's an half-baked option WHISPER_STATIC in CMakeLists.txt, that can be used if @ggerganov finds time to do this consistently across the compilers. It's half-baked imho because it is not declared as a cmake option and used in mostly GPU logic branches of CMakeLists.txt.
Anyway, I added the following lines
if (WHISPER_STATIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
endif()
and the following steps (assuming you already compiled the project once. If not just skip cleaning: steps)
cleaning: Delete build/CMakeCache.txt
cmake -B build -DWHISPER_STATIC=ON. This step is similar to the instruction, only the option provided
cleaning: cmake --build build --target clean . I had to do this otherwise ninja said there's nothing to do. I don't know whether this expected or not but in another cmake-based project deletion of CMakeCache.txt and configure was enough to trigger the project rebuild.
cmake --build build -j16 --config Release (this one's is the same from the instruction)
The executable now starts in general Windows, without msys2 environment. It accepts windows-style paths (with backslash ""), but needs OEM encoding for non-latin parts of the paths.
The only big (for me) question left for me is that while inferring non-lating, the outputted text in the console is garbage no matter what the encodings I chose for the msys2 shell, and I see the same garbage in the windows console. The file output is always ok (UTF-8)
@thewh1teagle, CUDA Build part probably no longer works for latest cmake (3.28.1). I already had a question to this part since the NAME variable is not mentioned anywhere in the following lines and OPENBLAS_PATH looks a little unrelated. What I managed to fix partly to make find_package(CUDAToolkit) happy is the second line replacement
now "cuBLAS found", but the script in the following lines can't detect CUDA architecture so I suspect I'm digging somewhere wrong (not to mentioning that my line is too long to look adequate).
now "cuBLAS found", but the script in the following lines can't detect CUDA architecture so I suspect I'm digging somewhere wrong (not to mentioning that my line is too long to look adequate).
Any thoughts?
I don't think it's possible to use CUDA when compiling inside msys2.
I don't think it's possible to use CUDA when compiling inside msys2.
I also met some short claims of impossibility, but now finally a notorious discussion about MinGW compatibility spanning 15 years, where the main fact is that nvcc.exe binary was and is hard-coded to cl.exe compiler (VC)
The disadvantages of using msys2, is that the binary won't run outside of that environment because it depended on msys2DLLs. The simplest way to compile whisper.cpp on Windows, is using msvc compiler (of Microsoft)
If you still need it, let me know and I'll provide instructions
I would appreciate detailed instructions on how to compile on Windows with msvc please...
I am new to the party and probably this is a dumb question, but is there a .exe that I can just download and run in my windows machine?
preferably without going through all the messages posted here in the last 2 years :)
Activity
regstuff commentedon Nov 22, 2022
Tested successfully on an i5-8300H. Failed on an old Pentium G4400.
If this works well, I suppose it would be a good idea to setup a Github Workflow to auto-compile whenever this repo is updated.
ggerganov commentedon Nov 22, 2022
@Topping1
Very nice!
Can you try cross-compiling using
x86_64-w64-mingw32-gcc-posix+-lwinpthreadwithout usingmingw-std-threads?I want to avoid adding the extra source files.
@regstuff
Yes - having a Github action to build a Windows executable would be great.
I think there are a lot of people that want to try Whisper on Windows without going through the hassle of compiling it.
Topping1 commentedon Nov 22, 2022
I will try and report back. By the way, when browsing https://github.com/ggerganov/whisper.cpp/actions I found the item
ggml : fix Windows build #225 https://github.com/ggerganov/whisper.cpp/actions/runs/3509700272, and at the end of the page you can find that the "Artifacts Produced during runtime" section contains two automatically compiled windows executables (win32 and win64). I have tried the 64bit version and works ok on windows 10. I guess you already implemented the github action a couple of days ago.
ggerganov commentedon Nov 22, 2022
Ah yes - I didn't even realise that the job already produces the executable. Not sure how to reference the latest one though - I would like to put a link the README.
I think it would be still useful to be able to cross compile using mingw, so if you get the chance to try it - let us know.
Topping1 commentedon Nov 22, 2022
Apparently, Github doesn´t have yet a way to reference the latest artifact from a build action (see https://stackoverflow.com/questions/60789862/url-of-the-last-artifact-of-a-github-action-build). In that stackoverflow question, a free service is mentioned that can generate a permanent link, for example https://nightly.link/ggerganov/whisper.cpp/actions/runs/3509700272/whisper-bin-x64.zip. Not sure if this link will work with new action runs, there is some documentation on the page that explains it in more detail.
Topping1 commentedon Nov 23, 2022
@ggerganov compiling with the POSIX version worked! In summary:
sudo apt install g++-mingw-w64-x86-64-posix
sudo apt install gcc-mingw-w64-x86-64-posix
In ggml.c line 18
change #include <Windows.h>
to
#include <windows.h>
#include <errno.h>
x86_64-w64-mingw32-gcc-posix -I. -O3 -std=c11 -mfma -mf16c -mavx -mavx2 -c ggml.c -o ggml.o
x86_64-w64-mingw32-g++-posix -I. -I./examples -O3 -std=c++11 -lwinpthread -c whisper.cpp -o whisper.o
x86_64-w64-mingw32-g++-posix -I. -I./examples -O3 -std=c++11 -static-libgcc -static-libstdc++ -lwinpthread examples/main/main.cpp ggml.o whisper.o -o main
This version still does not show correctly accented characters. I have tested the automatic win64 build and also shows this problem.
Topping1 commentedon Nov 23, 2022
@ggerganov I found a workaround (the problem might be with MinGW): before using main.exe on a command prompt window, execute the command chcp 65001 (UTF-8 encoding).
ggml : fix cross-compile Linux -> Window with mingw (#168)
ggerganov commentedon Nov 23, 2022
@Topping1 Thank you for the efforts. I just pushed the
windows.hfix on master and referenced this issue from the README for building with MinGW. If you want, you can update your original comment at the top of the thread with the latest instruction, so it is more visible when someone looks for the build steps.R4ZZ3 commentedon Nov 25, 2022
Hi,
Any more detailed instructions coming? I have been able to get this working on WSL2.
Now I tried with compiling with the instructions above using Ubunt22.04 in WSL2.
First I got error that libwinpthread-1.dll is missing. Downloaded it from here https://www.dll-files.com/download/1e0d62c34ff2e649ebc5c372065732ee/libwinpthread-1.dll.html?c=OVhZYVRGRklHdFNGQWQ2NTZ3ZGVPdz09 and put it in the project root.
Then I tried main.exe again but still running into error "application did not start correctly"
Topping1 commentedon Nov 27, 2022
@R4ZZ3 I have tried your setup (WSL2 but with ubuntu 20.04) with the instructions of the first message of this thread and could compile the file with no errors about libwinpthread-1.dll missing. Not sure what else can be happening. Maybe try to compile in a fresh install of a linux VM?
R4ZZ3 commentedon Nov 27, 2022
@Topping1
sudo apt install g++-mingw-w64-x86-64-posix
sudo apt install gcc-mingw-w64-x86-64-posix
For me these run into error with Ubuntu 20.04

R4ZZ3 commentedon Nov 27, 2022
But I did not yet test with fresh install. Trying that now
11 remaining items
fuzekun commentedon Apr 30, 2024
Thank you, it worked. It was because I did not run it inside msys2. Since I can't run directly on Windows, I'll use Linux instead. Thank you again.
thewh1teagle commentedon Apr 30, 2024
The disadvantages of using
msys2, is that the binary won't run outside of that environment because it depended onmsys2DLLs.The simplest way to compile
whisper.cpponWindows, is usingmsvccompiler (ofMicrosoft)If you still need it, let me know and I'll provide instructions
fuzekun commentedon Apr 30, 2024
No need to trouble yourself anymore, I have successfully compiled on Linux. Thank you very much for your kind assistance.
Codereamp commentedon Apr 30, 2024
@thewh1teagle, It would be great in general, preferably with command-line options and information about versions compatibility. Sometimes one can have some (ancient) msvc installed for some purpose in the past and it would be nice if some bat file with minor correction would also work with it.
Codereamp commentedon May 7, 2024
@thewh1teagle, I managed to make a static linking without much change to your routine, probably some minor questions along the way.
Basically there's an half-baked option WHISPER_STATIC in CMakeLists.txt, that can be used if @ggerganov finds time to do this consistently across the compilers. It's half-baked imho because it is not declared as a cmake option and used in mostly GPU logic branches of CMakeLists.txt.
Anyway, I added the following lines
and the following steps (assuming you already compiled the project once. If not just skip
cleaning:steps)build/CMakeCache.txtcmake -B build -DWHISPER_STATIC=ON. This step is similar to the instruction, only the option providedcmake --build build --target clean. I had to do this otherwise ninja said there's nothing to do. I don't know whether this expected or not but in another cmake-based project deletion of CMakeCache.txt and configure was enough to trigger the project rebuild.cmake --build build -j16 --config Release(this one's is the same from the instruction)The executable now starts in general Windows, without msys2 environment. It accepts windows-style paths (with backslash ""), but needs OEM encoding for non-latin parts of the paths.
The only big (for me) question left for me is that while inferring non-lating, the outputted text in the console is garbage no matter what the encodings I chose for the msys2 shell, and I see the same garbage in the windows console. The file output is always ok (UTF-8)
Codereamp commentedon May 10, 2024
@thewh1teagle, CUDA Build part probably no longer works for latest cmake (3.28.1). I already had a question to this part since the NAME variable is not mentioned anywhere in the following lines and OPENBLAS_PATH looks a little unrelated. What I managed to fix partly to make find_package(CUDAToolkit) happy is the second line replacement
now "cuBLAS found", but the script in the following lines can't detect CUDA architecture so I suspect I'm digging somewhere wrong (not to mentioning that my line is too long to look adequate).
Any thoughts?
thewh1teagle commentedon May 12, 2024
I don't think it's possible to use
CUDAwhen compiling insidemsys2.thewh1teagle commentedon May 12, 2024
I don't think it's possible to use
CUDAwhen compiling insidemsys2.Codereamp commentedon May 13, 2024
I also met some short claims of impossibility, but now finally a notorious discussion about MinGW compatibility spanning 15 years, where the main fact is that nvcc.exe binary was and is hard-coded to cl.exe compiler (VC)
BBC-Esq commentedon May 30, 2024
I would appreciate detailed instructions on how to compile on Windows with msvc please...
jralduaveuthey commentedon Jun 30, 2024
I am new to the party and probably this is a dumb question, but is there a .exe that I can just download and run in my windows machine?
preferably without going through all the messages posted here in the last 2 years :)
Kishlay-notabot commentedon Aug 16, 2024
@Topping1 did you find a solution?
BBC-Esq commentedon Aug 16, 2024
I did not
Kishlay-notabot commentedon Aug 25, 2024
can someone help me to compile
stream.cppfor windows? Thanks.Ghostown commentedon Dec 7, 2024
I can successfully build stream.cpp of both CPU and CUDA version on Windows11 with MSVC (using VScode only)