`
阅读更多

 

因需要使用 linux 下的 make 编译 lib 库,推出该章节。

 

当然也可以在 windows 下使用 make 编译,需要安装 mingw,以及使用 mingw-make.exe 来配置环境变量,然后可以使用 make 命令。

 

此处使用 Powershell 命令来安装 linux ,并使用 linux 来编译 lib 库。

 

先使用 Powershell 启动 Linux:Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

 

PS C:\Windows\system32> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux                                                                                                                                    
Path          :
Online        : True
RestartNeeded : False



PS C:\Windows\system32> cd C:\data
PS C:\data> Invoke-WebRequest -Uri https://wsldownload.azureedge.net/Ubuntu_1604.2019.523.0_x64.appx -OutFile Ubuntu.appx -UseBasicParsing
PS C:\data> dir


    Directory: C:\data


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         2/16/2022   4:11 PM      208755084 Ubuntu.appx


PS C:\data> Add-AppxPackage .Ubuntu.appx
Add-AppxPackage : Cannot find path 'C:\data\.Ubuntu.appx' because it does not exist.
At line:1 char:1
+ Add-AppxPackage .Ubuntu.appx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\data\.Ubuntu.appx:String) [Add-AppxPackage], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

PS C:\data> Add-AppxPackage .\Ubuntu.appx
PS C:\data>

 

 

然后在 Windows Start 中搜索 Ubuntu 并启动:

 

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: admin
Enter new UNIX password:
Retype new UNIX password:
Sorry, passwords do not match
passwd: Authentication token manipulation error
passwd: password unchanged
Try again? [y/N] y
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

admin@YK-SZPC00093:~$

 

 

然后可以使用 Linux 命令了

 

admin@YK-SZPC00093:~$ cmake -v
The program 'cmake' is currently not installed. You can install it by typing:
sudo apt install cmake
admin@YK-SZPC00093:~$ sudo apt install cmake
[sudo] password for jessea:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  binutils cmake-data cpp cpp-5 gcc gcc-5 libarchive13 libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5
  libcurl3 libgcc-5-dev libgomp1 libisl15 libitm1 libjsoncpp1 liblsan0 libmpc3 libmpx0 libquadmath0 libtsan0 libubsan0
  linux-libc-dev make manpages-dev
Suggested packages:
  binutils-doc codeblocks eclipse ninja-build cpp-doc gcc-5-locales gcc-multilib autoconf automake libtool flex bison
  gdb gcc-doc gcc-5-multilib gcc-5-doc libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan2-dbg liblsan0-dbg
  libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx0-dbg libquadmath0-dbg lrzip glibc-doc make-doc
The following NEW packages will be installed:
  binutils cmake cmake-data cpp cpp-5 gcc gcc-5 libarchive13 libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0
  libcilkrts5 libcurl3 libgcc-5-dev libgomp1 libisl15 libitm1 libjsoncpp1 liblsan0 libmpc3 libmpx0 libquadmath0
  libtsan0 libubsan0 linux-libc-dev make manpages-dev
0 upgraded, 29 newly installed, 0 to remove and 0 not upgraded.
Need to get 31.7 MB of archives.
After this operation, 122 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cmake-data all 3.5.1-1ubuntu3 [1,121 kB]
Err:2 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libarchive13 amd64 3.1.2-11ubuntu0.16.04.6
  404  Not Found [IP: 91.189.88.152 80]
Ign:3 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.12
Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 libjsoncpp1 amd64 1.7.2-1 [73.0 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cmake amd64 3.5.1-1ubuntu3 [2,623 kB]
Err:2 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libarchive13 amd64 3.1.2-11ubuntu0.16.04.6
  404  Not Found [IP: 91.189.88.152 80]
Err:3 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.12
  404  Not Found [IP: 91.189.88.152 80]
7% [5 cmake 883 kB/2,623 kB 34%]

 

 

这个版本的 linux 还是缺少很多库的,不是一个完整版本,可以看到 gcc 都没有安装:

Need to get 31.7 MB of archives.
After this operation, 122 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cmake-data all 3.5.1-1ubuntu3 [1,121 kB]
Err:2 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libarchive13 amd64 3.1.2-11ubuntu0.16.04.6
  404  Not Found [IP: 91.189.88.152 80]
Ign:3 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.12
Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 libjsoncpp1 amd64 1.7.2-1 [73.0 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cmake amd64 3.5.1-1ubuntu3 [2,623 kB]
Err:2 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libarchive13 amd64 3.1.2-11ubuntu0.16.04.6
  404  Not Found [IP: 91.189.88.152 80]
Err:3 http://security.ubuntu.com/ubuntu xenial-security/main amd64 libcurl3 amd64 7.47.0-1ubuntu2.12
  404  Not Found [IP: 91.189.88.152 80]
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 libmpc3 amd64 1.0.3-1 [39.7 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.8 [2,312 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial/main amd64 libisl15 amd64 0.16.1-1 [524 kB]
Err:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 cpp-5 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Get:10 http://archive.ubuntu.com/ubuntu xenial/main amd64 cpp amd64 4:5.3.1-1ubuntu1 [27.7 kB]
Err:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcc1-0 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:12 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgomp1 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libitm1 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:14 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libatomic1 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libasan2 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 liblsan0 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libtsan0 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:18 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libubsan0 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:19 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libcilkrts5 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:20 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libmpx0 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:21 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libquadmath0 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:22 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgcc-5-dev amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Err:23 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 gcc-5 amd64 5.4.0-6ubuntu1~16.04.11
  404  Not Found [IP: 91.189.88.152 80]
Get:24 http://archive.ubuntu.com/ubuntu xenial/main amd64 gcc amd64 4:5.3.1-1ubuntu1 [5,244 B]
Err:25 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc-dev-bin amd64 2.23-0ubuntu11
  404  Not Found [IP: 91.189.88.152 80]
Err:26 http://security.ubuntu.com/ubuntu xenial-security/main amd64 linux-libc-dev amd64 4.4.0-148.174
  404  Not Found [IP: 91.189.88.152 80]
Err:27 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libc6-dev amd64 2.23-0ubuntu11
  404  Not Found [IP: 91.189.88.152 80]
Get:28 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB]
Err:26 http://security.ubuntu.com/ubuntu xenial-security/main amd64 linux-libc-dev amd64 4.4.0-148.174
  404  Not Found [IP: 91.189.88.152 80]
Get:29 http://archive.ubuntu.com/ubuntu xenial/main amd64 manpages-dev all 4.04-2 [2,048 kB]
Fetched 8,924 kB in 35s (252 kB/s)
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/liba/libarchive/libarchive13_3.1.2-11ubuntu0.16.04.6_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/libcurl3_7.47.0-1ubuntu2.12_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/cpp-5_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libcc1-0_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libgomp1_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libitm1_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libatomic1_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libasan2_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/liblsan0_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libtsan0_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libubsan0_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libcilkrts5_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libmpx0_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libquadmath0_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/libgcc-5-dev_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/gcc-5/gcc-5_5.4.0-6ubuntu1~16.04.11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-dev-bin_2.23-0ubuntu11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_4.4.0-148.174_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.23-0ubuntu11_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
admin@YK-SZPC00093:~$ gcc -v
The program 'gcc' is currently not installed. You can install it by typing:
sudo apt install gcc
admin@YK-SZPC00093:~$ sudo apt install gcc

 

后续只需要使用命令安装好所需的软件和环境就好。

 

 

Powershell 卸载 Linux :

 

//获取 linux name
>Get-AppxPackage *ubuntu*
//从结果中拿到 Name:CanonicalGroupLimited.Ubuntu16.04onWindows,然后执行以下
>Get-AppxPackage CanonicalGroupLimited.Ubuntu16.04onWindows | Remove-AppxPackage

 

Powershell 禁用 Linux:

>Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

 

 

1
1
分享到:
评论

相关推荐

    powershell-6.1.0-linux-x64.tar.gz

    在Windows系统中,PowerShell是默认的管理工具,而在Linux上,它是跨平台的,允许Linux和macOS用户使用PowerShell的强大功能,如对象化输出、管道和模块化脚本编写。 标签中提到了"shell",指的是命令行解释器,也...

    PowerShell.Linux.x64.7.0.0-rc.2.nupkg

    我不能用官方的镜像,因为我需要在小伙伴构建的 debian 镜像上面安装 dotnet sdk 用来做构建,其实在 docker 里面需要找到一个个文件,然后复制代码

    PowerShell-WSL-Interop:使用PowerShell和Linux的Windows子系统(WSL)将Linux命令集成到Windows中

    因此作为参数传递的Windows路径通常无法解析作为参数传递的Windows路径由于未转换为WSL中的适当安装点而通常无法解析带有特殊字符的参数(例如正则表达式)通常会被误解而没有不自然的嵌入式引号或转义序列不支持WSL...

    PowerShell-7.2.6-win-x64安装下载 支持中文版

    PowerShell是一种强大的命令行接口和脚本语言,主要用于自动化和配置Windows操作系统以及处理与系统管理相关的任务。...记得在安装过程中阅读README文件,以获取更多关于安装和使用PowerShell的详细信息。

    PowerShell v7.2.4 最新64位安装包 PowerShell-7.2.4-win-x64.msi

    首先,PowerShell 7引入了跨平台支持,这意味着它不仅能在Windows上运行,还能在Linux和macOS等其他操作系统上使用。这一特性使得系统管理员和开发者可以在不同平台上使用统一的命令行接口和脚本,大大提高了工作...

    绿色免安装pshell(PowerShell)

    **绿色免安装pshell...总之,绿色免安装pshell是一个实用的工具,它将PowerShell、SSH和FTP功能完美结合,为Windows用户提供了便捷的Linux系统管理和文件传输体验,特别适合IT专业人士和开发者日常工作中使用。

    dotnet-PowerShell是跨平台WindowsLinux和OSX自动化和配置工具框架

    这个“dotnet-PowerShell”很可能是指在.NET Core环境下使用的PowerShell版本,它旨在提供一致的自动化体验,无论你使用哪种操作系统。 PowerShell的核心组件包括: 1. **PowerShell Console**: 提供了一个交互式...

    powershell

    3. **提供管道**:PowerShell支持管道机制,允许用户将一个命令的输出作为另一个命令的输入,类似于Unix/Linux中的管道操作。 4. **提供别名和函数**:为了方便用户,PowerShell允许创建别名,可以将复杂的Cmdlet或...

    PowerShell-7.0.0-win-x64.zip

    这意味着Windows PowerShell和PowerShell Core用户将能够在Windows、Linux和macOS上跨越使用相同版本的PowerShell,而PowerShell 7用户将与他们所依赖的Windows PowerShell模块具有非常高的兼容性。

    内容-powershell-linux-管理员

    1. **安装PowerShell**: 在Linux系统上,可以通过包管理器(如apt或yum)来安装PowerShell。例如,在Ubuntu上,可以使用`sudo apt-get install powershell`命令,而在CentOS/RHEL上,可以使用`sudo yum install epel...

    windows和linux下python opencv安装(含离线安装)

    本篇将详细介绍在Windows和Linux环境下如何安装Python OpenCV,包括使用pip以及离线安装的方法。 ### Windows上的Python OpenCV安装 #### 1. 使用pip 首先,确保你的系统已经安装了Python和pip。在命令提示符或...

    PowerShell Server 2016.zip

    在Windows服务器上安装SSH(Secure Shell)是实现与Linux和Unix系统跨平台交互的重要步骤,同时也可以在Windows环境中安全地进行远程管理。 SSH是一种网络协议,用于安全地在网络之间传输数据,特别是在执行命令行...

    Powershell

    - **适用场景**:虽然VBScript仍然有其应用场景,但对于新项目或复杂任务,推荐使用Powershell。 4. **Powershell与Perl** - **背景**:Perl是一种广泛应用的脚本语言,尤其擅长文本处理。 - **对比**: - Perl...

    PowerShellServer 2016 installation.zip

    - 配置:安装完成后,需要在服务器上配置防火墙规则,允许PowerShell Server使用的端口通过,并设置必要的权限和访问控制策略。 - 验证:最后,测试从远程机器连接到PowerShell Server,确保一切正常运行。 4. ...

    WindowsPowerShell v1.0

    Windows PowerShell是微软为Windows操作系统开发的一...然而,对于最新的系统管理需求,建议使用更新的PowerShell版本,例如Windows PowerShell v5.1或更现代的PowerShell Core(跨平台,支持Windows、Linux和macOS)。

    powershell for XP

    PowerShell是微软公司于2006年第四季度正式发布的. 它的出现标志着, 微软公司向服务器领域迈出了重要的一步, 拉近了与Unix, Linux等操作系统的距离.... 可以预期, 使用PowerShell管理Windows服务器指日可待.

    Windows Powershell

    在最新版本中,PowerShell Core支持跨平台使用,这意味着它可以在非Windows平台上运行,包括Linux和macOS,这增强了其在多平台开发和部署环境中的适用性。 由于PowerShell的灵活性和功能强大,它成为了很多IT专业...

    PowerShell_Setup_x86.rar

    **管道机制**:类似于Unix/Linux中的管道,PowerShell允许用户将一个命令的输出作为另一个命令的输入,实现数据流的传递,如`Get-Process | Sort-Object -Property CPU | Select-Object -First 5`可以获取CPU使用率...

    PowerShell-7.1.3-win-x64.rar

    PowerShell 7.1.3是该系列的最新版本,支持Windows、Linux和macOS等跨平台操作。这个压缩包“PowerShell-7.1.3-win-x64.rar”是针对64位Windows系统的PowerShell 7.1.3安装程序。 PowerShell的核心特性包括: 1. **...

    PowerShell 开源啦!.zip

    " 这个口号揭示了其跨平台的目标,旨在打破Windows操作系统的局限,让Unix、Linux等其他系统也能无缝使用PowerShell。 PowerShell的核心是它强大的命令行接口,它引入了对象级管道,使得数据处理更加高效。传统的...

Global site tag (gtag.js) - Google Analytics