Issues when building under Windows
Environment
Windows 11
Description
Hi there, when trying to build r2 then I face these problems:
running preconfigure
Does only succeed when invoked within a Visual Studio developer console. In a normal terminal the process fails when looking for VS:
Your current Host Architecture is amd64
Please select the Target Architecture:
1. x86
2. amd64 [x64]
3. arm
4. arm64
Enter your choice (1-4): 2
VSARCH is set to: amd64
=== Finding Visual Studio...
Syntaxfehler. <-- syntax error
running configure
sdb| Subproject sdb finished.
meson.build:513:0: ERROR: Program 'cp' not found or not executable
A full log can be found at C:\Users\vboxuser\Desktop\radare2_compiled\vs\meson-logs\meson-log.txt
VS failed Try running 'preconfigure'
Currently I am stuck here but will keep on reporting step by step.
Can you try to fix this syntax error problem in the batch file?
Hi, no because I don't have a clue what's the actual syntax error :-) And as I said: Running the batch file in a VS developer console instead of a normal terminal then the error does not appear. Seems like the developer console loads some more environmental stuff that is needed.
try this preconfigured.bat and confirm the syntax error is gone please https://github.com/radareorg/radare2/pull/24061
try again
Hi @trufae , the error is gone 🎉 Unfortunately there is more:
(venv) C:\Users\vboxuser\Desktop\radare2_compiled>configure
The Meson build system
Version: 0.61.99
Source dir: C:\Users\vboxuser\Desktop\radare2_compiled
Build dir: C:\Users\vboxuser\Desktop\radare2_compiled\vs
Build type: native build
WARNING: Project targeting '>=0.50' but tried to use feature introduced in '0.55.0': Wrap files with patch_directory.
Project name: radare2
Project version: 5.9.9
meson.build:1:0: ERROR: Compiler cl can not compile programs.
A full log can be found at C:\Users\vboxuser\Desktop\radare2_compiled\vs\meson-logs\meson-log.txt
VS failed Try running 'preconfigure'
Build started at 2025-03-12T22:07:19.325173
Main binary: C:\Users\vboxuser\Desktop\radare2_compiled\venv\Scripts\python.exe
Build Options: -Dsdb_cgen=false -Dc_std=c11 -Dbackend=vs
Python system: Windows
The Meson build system
Version: 0.61.99
Source dir: C:\Users\vboxuser\Desktop\radare2_compiled
Build dir: C:\Users\vboxuser\Desktop\radare2_compiled\vs
Build type: native build
WARNING: Project targeting '>=0.50' but tried to use feature introduced in '0.55.0': Wrap files with patch_directory.
Project name: radare2
Project version: 5.9.9
Sanity testing C compiler: cl
Is cross compiler: False.
Sanity check compiler command line: cl sanitycheckc.c /Fesanitycheckc.exe /MDd /nologo /showIncludes /utf-8 /link
Sanity check compile stdout:
sanitycheckc.c
LINK : fatal error LNK1104: Datei "MSVCRTD.lib" kann nicht ge ffnet werden.
-----
Sanity check compile stderr:
-----
meson.build:1:0: ERROR: Compiler cl can not compile programs.
regarding the MSVCRTD.lib I see a lot of stuff that might be the cause but the most important thing: The file exists. Thats not the problem ;) Besides that the search for the cause is a rabbithole...
You are using an ancient meson. (0.x) latest is 1.7
The ci builds fine with visual studio 2019, 2022 at least and mingw compilers too. So i guess the problem must be in your side now
Hm, isn't meson installed by your tool chain? Via preconfigure? At least I am not aware that I installed meson onto the VM by my own. Can you confirm that?
And I am using VS 2022 free edition.
uh seems like a lefotver i was not considering here. yeah, the preconfigure is installing an old meson. lemme fix
Try again. You must rimraf the venv directory
Here we go:
VSARCH is set to: amd64
=== Finding Visual Studio...
"Found 2022 Community edition"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.13.3
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Now you can run 'configure'
Microsoft Windows [Version 10.0.26100.2605]
(c) Microsoft Corporation. Alle Rechte vorbehalten.
(venv) C:\Users\vboxuser\Desktop\radare2_compiled>configure
The Meson build system
Version: 1.7.0
Source dir: C:\Users\vboxuser\Desktop\radare2_compiled
Build dir: C:\Users\vboxuser\Desktop\radare2_compiled\vs
Build type: native build
WARNING: Project targets '>=0.50' but uses feature introduced in '0.55.0': Wrap files with patch_directory.
Project name: radare2
Project version: 5.9.9
meson.build:1:0: ERROR: Compiler cl cannot compile programs.
A full log can be found at C:\Users\vboxuser\Desktop\radare2_compiled\vs\meson-logs\meson-log.txt
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
VS failed Try running 'preconfigure'
meson-log.txt
-----------
stderr:
Microsoft (R) C/C++-Optimierungscompiler Version 19.43.34809 f r x64
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
-----------
Sanity testing C compiler: cl
Is cross compiler: False.
Sanity check compiler command line: cl sanitycheckc.c /Fesanitycheckc.exe /MDd /nologo /showIncludes /utf-8 /link
Sanity check compile stdout:
sanitycheckc.c
LINK : fatal error LNK1104: Datei "MSVCRTD.lib" kann nicht ge ffnet werden.
-----
Sanity check compile stderr:
-----
meson.build:1:0: ERROR: Compiler cl cannot compile programs.
When using a VS Developer shell, activating the venv there then the configure commands succeeds.
After that the make command fails.
Calling ninja -C b install in isolation leads to:
Running custom install script 'C:\\Users\\vboxuser\\Desktop\\radare2_compiled\\sys/create_r2.bat'
(venv) C:\Users\vboxuser\Desktop\radare2_compiled\b>MKDIR c:/\bin
Syntaxfehler.
Das System kann den angegebenen Pfad nicht finden.
(venv) C:\Users\vboxuser\Desktop\radare2_compiled\b>EXIT 0
Seems like MESON_INSTALL_PREFIX is not set in create_r2.bat
In this code base I can't find where it shall been set before the make command. Googling the variable does not lead to an official documentation about this one so it seems to me that it will not be populated by the meson installation. Where should this variable point to?
you must pass —prefix or set the environment to tell meson where to compile and install the programs and i think this is a windows specific problem. On unix we have /usr. On windows you can set it to c:\radare2 i guess
But shouldn't the .bat file handle all this for me? Or otherwise if not wanted maybe you could add a paragraph to the readme?
ive been building radare on windows for more than 15 years without any of those issues, same goes for the CI, imho documenting stuff that should be done without user interaction is a bad idea. can you please confirm if setting that variable is enough for you to get it to work? imho the default prefix on windows should be .\.
I'm asking because it seems like your setup differs from the ones i have so it's better if you can test that and we can ship a generic fix that works everywhere
Hi, thanks for helping out. I am not quite sure If we are talking about the same already :) Lets see. And I also really don't want something documented that does not need interaction. But here it is not working in an automated manner.
One question in advance: What do you mean by " —prefix" <- is the dash intended?
Are more complete overview of what I have so far: Within radare2_compiled (the dir where I cloned the source to) there is a prefix directory which contains all built binaries:
this prefix dir is set here: https://github.com/radareorg/radare2/blob/0fa4113143ba38945c737496a508cff388d452ba/make.bat#L13
Then this line fails: https://github.com/radareorg/radare2/blob/0fa4113143ba38945c737496a508cff388d452ba/make.bat#L16 because it calls create_r2.bat which needs MESON_INSTALL_PREFIX to be available (https://github.com/radareorg/radare2/blob/0fa4113143ba38945c737496a508cff388d452ba/sys/create_r2.bat#L1). But as far as I can tell MESON_INSTALL_PREFIX is not set during prior steps. At least I cannot find a hint in the source where this happens.
Is this something helpful or do I miss something here?
And in terms of environment:
I am using a win 11 vm that is pretty fresh. Then I installed VS 2022 with all the C++ workloads which I thought seemed to be the only thing I needed. The docs do not mention anything else to be done prior to a build attempt. Except meson which is installed automatically.
I would say your current build pipeline is also facing this issue with the missing directory:
https://github.com/radareorg/radare2/actions/runs/13904115089/job/38902847543#step:9:5225
But that does not seem to matter a lot. Because the step that fails at the end would just copy the r2.bat into the radare2\prefix\bin directory if the path would be set correctly to this dir. So all binaries are ready to use but a last .bat does not get copied. Maybe this is why you didn't recognize this as an actual error?
Had some spare time to boot my windows box and im reproducing and ifxing all your issues.
First one goes here https://github.com/radareorg/radare2/pull/24081
can you try again and check what's missing now? i will give another turn with the remaining problems
Hi,
here is the current state:
configure ended in two errors:
[notice] A new release of pip is available: 22.0.4 -> 25.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip
ERROR: To modify pip, please run the following command:
C:\Users\vboxuser\Desktop\radare_compiled_260325\venv\Scripts\python.exe -m pip install -UI pip ninja meson
Solution: Run python.exe -m pip install -UI pip ninja meson in the manually activated venv
VSARCH is set to: amd64
=== Finding Visual Studio...
"Found 2022 Community edition"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.13.3
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
FAILED TO SETUP VISUAL STUDIO
Solution: I powered on the dev shell on my own.
Then I ran make:
[1600/1600] Linking target test/unit/test_crbtree.exe
Bibliothek "test\unit\test_crbtree.lib" und Objekt "test\unit\test_crbtree.exp" werden erstellt.
Installing r2 in C:\Users\vboxuser\Desktop\radare_compiled_260325\prefix
Syntaxfehler.
Das System kann den angegebenen Pfad nicht finden.
Das System kann den angegebenen Pfad nicht finden.
Das System kann den angegebenen Pfad nicht finden.
0 Datei(en) kopiert.
That still https://github.com/radareorg/radare2/issues/24054#issuecomment-2730417136
@stevenengland did you try the msys2 way
I have the same error. Is the build pipeline for windows still broken ?
I have the same error. Is the build pipeline for windows still broken ?
it seems to work on mingw
An exception occurred when running the script .\preconfigure.bat:
=== Finding Python...
OK
=== Finding Git...
OK
Already up to date.
=== Testing for meson and ninja...
FOUND
Your current Host Architecture is amd64
Please select the Target Architecture:
1. x86
2. amd64 [x64]
3. arm
4. arm64
Enter your choice (1-4): 2
VSARCH is set to: amd64
=== Finding Visual Studio...
"Found 2022 Community edition"
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.14.12
** Copyright (c) 2025 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
FAILED TO SETUP VISUAL STUDIO
An exception occurred when running the script
.\preconfigure.bat:=== Finding Python... OK === Finding Git... OK Already up to date. === Testing for meson and ninja... FOUND Your current Host Architecture is amd64 Please select the Target Architecture: 1. x86 2. amd64 [x64] 3. arm 4. arm64 Enter your choice (1-4): 2 VSARCH is set to: amd64 === Finding Visual Studio... "Found 2022 Community edition" ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.14.12 ** Copyright (c) 2025 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' FAILED TO SETUP VISUAL STUDIO
just use msys2
This error means that your installation was not properly detected. Read the script and fix it
it is now fixed?