-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Tutorial: compile for Windows on Linux with MinGW (cross compile) #168
Comments
Tested successfully on an i5-8300H. Failed on an old Pentium G4400. |
@Topping1
I want to avoid adding the extra source files. @regstuff |
I will try and report back. By the way, when browsing https://github.com/ggerganov/whisper.cpp/actions I found the item |
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. |
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. |
@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 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. |
@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 |
Hi, Any more detailed instructions coming? I have been able to get this working on WSL2. 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? |
@Topping1 |
But I did not yet test with fresh install. Trying that now |
Ended up using Debian. Still got that same libwinpthread-1.dll is missing error but after putting that file in the same folder as the main.exe got it working. Windows 11, BUILD 22000.1219, Processor 11th Gen Intel(R) Core(TM) i5-11600K @ 3.90GHz, 3912 Mhz, 6 Core(s), 12 Logical Processor(s) |
I had no luck until i removed "-mavx2" option on the gcc compile. It still needs the libwinpthreads-1.dll in same folder. |
For those of you using old processors, code that was released after v1.04 seemed to cause a crash. |
Simple way to build it on
|
Hey can you help me with setup cause i have to show it into my college in few days and i cant solve error because i dont have much knowledge how can i change some things so my faculty cant find out that i |
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).
|
Hi everyone, i have tried the option with CUDA by @kaushal2012 "Simple way to build it on msys2 in Windows:" My Output is: linko@msa-gaming UCRT64 /c/Users/linko/Desktop/ai/whisper.cpp Use WHISPER_CUDA instead -- Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4/include (found version "12.4.99")
is not able to compile a simple test program. It fails with the following output:
CMake will not be able to correctly generate this project. -- Configuring incomplete, errors occurred! |
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
|
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. |
The disadvantages of using 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.
|
@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. |
@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
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). Any thoughts? |
I don't think it's possible to use |
I don't think it's possible to use |
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) |
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? |
I did not |
can someone help me to compile |
First, install MinGW
sudo apt install g -mingw-w64-x86-64-posix
sudo apt install gcc-mingw-w64-x86-64-posix
Then, clone the repository
git clone https://github.com/ggerganov/whisper.cpp
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
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.
The text was updated successfully, but these errors were encountered: