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
Considering an existing third-party project which is managed by meson, how would you build that project on a Windows Intel host using Visual Studio for an ARM64 target?
This looks like a simple question. In fact, when using other build tools such as msbuild or cmake, it is as simple as msbuild /property:Platform=ARM64 or cmake -A ARM64.
However, using meson, it seems extremely complicated. This use case becomes of course relatively common and the question has been asked many times online. Surprisingly, I have found zero clear and complete answer. Just hypotheses, tests, various partially described dirty hacks, quite often applicable to a single project. Nothing specific. Nothing reliable. Nothing that works in my case.
The solution should be simple. Windows systems run on 3 majors architectures: Win32/x86, Win64/x64, ARM64. Using Visual Studio and the tool suite which comes with it, you can build from any host platform to any target platform. In some environments, we call that cross-compilation and it needs some specific configuration and setup. In the Windows environment, it's just compilation, all targets are equal, no specific environment, just specify a target name "Win32", "x64", "ARM64".
Quite often, in the numerous posts I have read, the answer to the question is "use a cross file". Alright, but what would be its content? No clue. It's simpler to say "use that" than giving precise details. I don't even see why we should describe a cross-build environment. Remember that, in the context of Visual Studio, this is only one single name in a project file, one single name in a command line parameter.
I understand that a cross file can be needed when you use non-standard tools, when you build to some specific embedded device, using a proprietary SDK for instance. But here, Visual Studio is an integrated environment where there is no difference between targets, native or cross. All the dirty configuration of using which and what is already integrated inside Visual Studio. Why would we need to reinvent the wheel in a meson cross file?
FYI, my context is the following. I develop and maintain an open source project named TSDuck which works on Linux, macOS, BSD, and Windows. This project uses a couple of third-party libraries which need to be rebuilt on Windows, for all target architectures (on Linux and macOS, all distros already include them). One library is built with cmake, the other one with meson. I am familiar with none of these two, even less with meson.
Based on various online information, I tried several solutions without luck. So far, with only Win32/x86 and Win64/x64, using the environment variables from the various VS-supplied scripts such as vcvarsamd64_x86.bat and the like was sufficient. However, it no longer works when you add ARM64. Using the scripts alone, outside a meson project, you can build a x86 or ARM64 project. Using meson, on the other hand, building for x86 works but building for ARM64 fails. This method is probably a hack, so I am not surprised it works in some cases only.
Could we use this discussion thread to build, with the help of meson experts, a definitive and complete response to the simple question: how to build a meson project for any other target on Windows using Visual Studio?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
Considering an existing third-party project which is managed by meson, how would you build that project on a Windows Intel host using Visual Studio for an ARM64 target?
This looks like a simple question. In fact, when using other build tools such as msbuild or cmake, it is as simple as
msbuild /property:Platform=ARM64
orcmake -A ARM64
.However, using meson, it seems extremely complicated. This use case becomes of course relatively common and the question has been asked many times online. Surprisingly, I have found zero clear and complete answer. Just hypotheses, tests, various partially described dirty hacks, quite often applicable to a single project. Nothing specific. Nothing reliable. Nothing that works in my case.
The solution should be simple. Windows systems run on 3 majors architectures: Win32/x86, Win64/x64, ARM64. Using Visual Studio and the tool suite which comes with it, you can build from any host platform to any target platform. In some environments, we call that cross-compilation and it needs some specific configuration and setup. In the Windows environment, it's just compilation, all targets are equal, no specific environment, just specify a target name "Win32", "x64", "ARM64".
Quite often, in the numerous posts I have read, the answer to the question is "use a cross file". Alright, but what would be its content? No clue. It's simpler to say "use that" than giving precise details. I don't even see why we should describe a cross-build environment. Remember that, in the context of Visual Studio, this is only one single name in a project file, one single name in a command line parameter.
I understand that a cross file can be needed when you use non-standard tools, when you build to some specific embedded device, using a proprietary SDK for instance. But here, Visual Studio is an integrated environment where there is no difference between targets, native or cross. All the dirty configuration of using which and what is already integrated inside Visual Studio. Why would we need to reinvent the wheel in a meson cross file?
FYI, my context is the following. I develop and maintain an open source project named TSDuck which works on Linux, macOS, BSD, and Windows. This project uses a couple of third-party libraries which need to be rebuilt on Windows, for all target architectures (on Linux and macOS, all distros already include them). One library is built with cmake, the other one with meson. I am familiar with none of these two, even less with meson.
Based on various online information, I tried several solutions without luck. So far, with only Win32/x86 and Win64/x64, using the environment variables from the various VS-supplied scripts such as
vcvarsamd64_x86.bat
and the like was sufficient. However, it no longer works when you add ARM64. Using the scripts alone, outside a meson project, you can build a x86 or ARM64 project. Using meson, on the other hand, building for x86 works but building for ARM64 fails. This method is probably a hack, so I am not surprised it works in some cases only.Could we use this discussion thread to build, with the help of meson experts, a definitive and complete response to the simple question: how to build a meson project for any other target on Windows using Visual Studio?
Beta Was this translation helpful? Give feedback.
All reactions