📜 ⬆️ ⬇️

Linux Mood Color, Mac OS Mood Color

Stereotypes are long gone. Today, Microsoft adheres to the concept of "any developer, any application, any platform." Today we will tell you about vcpkg, a cross-platform package manager designed for quick installation of C / C ++ libraries, which is now available not only for Windows, but also for Linux and Mac OS. Look under the cat!



Now you can instantly get access to the vcpkg directory with the C ++ libraries on two more platforms by performing just two simple steps familiar from Windows and UWP.
')
The vcpkg plug-in has come a long way since its first presentation at CppCon-2016. At first there were only 20 libraries, but in the past 19 months their number has grown incredibly - more than 900! This is the invaluable merit of the wonderful members of our community.

Judging by your feedback, support for Linux and Mac systems turned out to be the most sought-after potential opportunity. And today we see that the vcpkg plug-in has become available to a much larger number of users, simplifying cross-platform access to even more C ++ libraries. Today we offer you to evaluate work with vcpkg on Windows, Linux or Mac OS.

Using vcpkg on Linux and Mac


The vcpkg plug-in now supports compatibility with Linux, Mac, and other POSIX systems. This was only possible thanks to the personal contribution of several great community members to the development.

At the time of writing this blog post for Linux and Mac, there were over 300 libraries, and we expect that soon there will be much more. Currently, vcpkg is being tested on Ubuntu-LTS 16.04 / 18.04, we have successfully tested this new tool in Arch, Fedora and FreeBSD.

Beginning of work


  1. Clone the vcpkg repository: git clone https://github.com/Microsoft/vcpkg
  2. Start the vcpkg bootloader: ./bootstrap-vcpkg.sh
  3. After installing vcpkg, you can create any library using the following syntax:
    vcpkg install sdl2

    It will install sdl2:x64-linux (the default is the stationary 64-bit version, while the only one available for Linux).

    The result (.h, .lib) is saved to the same folder tree, and this folder should be referenced in the build management system configuration.
  4. Work with the created library:
    • If you use CMake as an CMAKE_TOOLCHAIN_FILE management system, use CMAKE_TOOLCHAIN_FILE to open libraries for `find_package()` . For example: cmake .. “-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake” .
    • You must link to the vcpkg folder, which contains the headers (\ vcpkg \ installed \ x64-linux \ include), as well as the .lib folder (\ vcpkg \ installed \ x64-linux \ lib) to create the project using the generated libraries .





Using vcpkg to bind to Linux from Windows via WSL


Since WSL is a Linux system, we will use it like Linux. Having correctly set up once, you will create Linux libraries on a computer running Windows just as if they were generated in the Linux sandbox. Follow the instructions used for installation on Linux. See instructions for installing WSL in Windows 10 and configuring with the Visual Studio extension for Linux.



As shown in the screenshot above, the vcpkg directory can be accessed from both Windows and WSL. In this example, sdl2 and sqlite3 were built in WSL (binary codes for Linux); sqlite3 is also designed for Windows (Windows dll).

Conclusion


Install vcpkg package manager in Linux or Mac, test it in your cross-platform projects, share your impressions and tell us what else we can improve.

Your feedback and comments are really very important to us. To share your opinion or ask a question, create a message on GitHub or send us an email to vcpkg @ microsoft.com . We will also be grateful if you find a couple of minutes to participate in our survey.

about the author


Eric Mitlett is a senior program manager on the VC ++ team. He owns the libraries (STL, VC Runtime CPPRestSDK FC / ATL and vcpkg). Participated in the creation and presentation of vcpkg 18 months ago. Initially, 20 libraries, now more than 900. In addition, they are now supported by Linux and Mac. If you have questions, you can write to Eric: ericmitt @ microsoft.com .

Source: https://habr.com/ru/post/354626/


All Articles