Visual Studio 2022 Preview 2 adds C++ build and debugging in WSL2 distributions

Fancy a spot of weekend tinkering?

Amid the puffery over Windows 365, Microsoft also released the second preview of Visual Studio 2022 with some intriguing features for Windows Subsystem for Linux 2 users.

Visual Studio 2022, now finally available in 64-bit flavour, also added a range of additional languages in the update and new Live Preview experiences for XAML and web apps. However, for developers toiling away at the coalface of C++, the availability of a native Windows Subsystem for Linux 2 (WSL2) toolset should make life a little simpler.

WSL2 is Microsoft's latest and greatest attempt at bringing Linux apps to Windows. Where its predecessor was a translation layer, the new shiny runs in a lightweight virtual machine and sports a full Linux kernel for much improved system call compatibility.

WSL1, however, still had the edge with the native WSL1 toolset introduced in Visual Studio 2019 16.1, which permitted the building and debugging of C++ code on WSL1 distros.

Preview 2 (and goodness, this is very much a preview and not really ready for production workloads as yet) adds the WSL2 toolset, allowing the C++ code debugging on WSL2 distros without having to faff around with the likes of SSH connections.

While the toolset supports both CMake and MSBuild-based Linux projects, Microsoft recommends going for CMake for cross-platform development "because it allows you to build and debug the same project on Windows, WSL, and remote systems."

We took the new toys out for a spin, adding the extra danger of a preview build of Windows 10 to the not-for-production emission of Visual Studio 2022 and came away impressed by the potential, even if we stumbled a bit with the implementation (but will cut the code some slack, it being relatively early days in development). Admittedly, our crude "Hello world!" hardly taxed things, but was neat nonetheless.

As for how it works, Visual Studio executes a local rsync to shunt files from the Windows file system to WSL. Hitting Start in Visual Studio 2022 launches the executable on the WSL2 distribution and the output is squirted out into the Linux Console window of VS. Breakpoints and the like work as expected for debugging.

There are dependencies. A C++ compiler is required in the distro as well as tools including rsync, zip, and, of course, CMake. CMake Presets integration must also be enabled in Visual Studio.

However, once done (and the WSL2 target distribution selected), the process is painless and stable. At least it was in the case of our simple app. We'd recommend some experimentation with the technology if C++, Visual Studio and cross-platform development is your thing.

While this remains in preview, it is yet another demonstration of Microsoft's determination to embrace a cross-platform world. ®

Other stories you might like

  • World’s smallest remote-controlled robots are smaller than a flea
    So small, you can't feel it crawl

    Video Robot boffins have revealed they've created a half-millimeter wide remote-controlled walking robot that resembles a crab, and hope it will one day perform tasks in tiny crevices.

    In a paper published in the journal Science Robotics , the boffins said they had in mind applications like minimally invasive surgery or manipulation of cells or tissue in biological research.

    With a round tick-like body and 10 protruding legs, the smaller-than-a-flea robot crab can bend, twist, crawl, walk, turn and even jump. The machines can move at an average speed of half their body length per second - a huge challenge at such a small scale, said the boffins.

    Continue reading
  • IBM-powered Mayflower robo-ship once again tries to cross Atlantic
    Whaddayaknow? It's made it more than halfway to America

    The autonomous Mayflower ship is making another attempt at a transatlantic journey from the UK to the US, after engineers hauled the vessel to port and fixed a technical glitch. 

    Built by ProMare, a non-profit organization focused on marine research, and IBM, the Mayflower set sail on April 28, beginning its over 3,000-mile voyage across the Atlantic Ocean. But after less than two weeks, the crewless ship broke down and was brought back to port in Horta in the Azores, 850 miles off the coast of Portugal, for engineers to inspect.

    With no humans onboard, the Mayflower Autonomous Ship (MAS) can only rely on its numerous cameras, sensors, equipment controllers, and various bits of hardware running machine-learning algorithms to survive. The computer-vision software helps it navigate through choppy waters and avoid objects that may be in its path.

    Continue reading
  • Revealed: The semi-secret list of techs Beijing really really wishes it didn't have to import
    I think we can all agree that China is not alone in wishing it had an alternative to Microsoft Windows

    China has identified "chokepoints" that leave it dependent on foreign countries for key technologies, and the US-based Center for Security and Emerging Technology (CSET) claims to have translated and published key document that name the technologies about which Beijing is most worried.

    CSET considered 35 articles published in Science and Technology Daily from April until July 2018. Each story detailed a different “chokepoint” or tech import dependency that China faces. The pieces are complete with insights from Chinese academics, industry insiders and other experts.

    CSET said the items, which offer a rare admission of economic and technological vulnerability , have hitherto “largely unnoticed in the non-Chinese speaking world.”

    Continue reading

Biting the hand that feeds IT © 1998–2022