0
点赞
收藏
分享

微信扫一扫

WSL:运行Linux文件

程序猿不脱发2 2022-01-23 阅读 55

简介:搭建完成wsl后,可以运行原生Linux二进制可执行文件。

案例1:执行go可执行文件。

go源码:main.go

package main

import (
  "fmt"
  "time"
)

func say(s string) {
  for i := 0; i < 3; i++ {
    time.Sleep(100 * time.Millisecond)
    fmt.Println(s)
  }
}

func main() {
  go say("world")
  say("hello")
}

编译,执行:

go bulid main.go
./main

图片

案例2:执行C可执行文件。

C源码:hello.c

#include <unistd.h>
#include <stdio.h>
int main()
{
    printf("Hello World !\n");
}

编译,执行:

gcc -o hello.out hello.c
./hello.out

在这里插入图片描述

微信公众号:玩转测试开发
欢迎关注,共同进步,谢谢!

在这里插入图片描述

举报

相关推荐

0 条评论