clion 开始支持wsl环境了,win 10 可以方便的直接编译linux的pthread,socket等相关内容,可以在直接愉快的浏览相关源码了

需要用到的是ubuntu on windows,还不是直接 添加删除程序里的,适用于Linux 的Windows子系统

sudo vi /etc/ssh/sshd_config

UsePrivilegeSeparation no
PasswordAuthentication yes
ListenAddress 0.0.0.0

关win10 自带SSH服务

sudo /usr/sbin/sshd -d

ssh username@localhost -v

sshd -d 里可以看到 No supported key exchange algorithms

解决用

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key

sudo service ssh --full-restart

sudo visudo
$username ALL=(ALL) NOPASSWD: /usr/sbin/sshd -D
#include <iostream>
#include<stdio.h>
#include<pthread.h>
#include<string.h>
#include<sys/types.h>
#include<unistd.h>

pthread_t main_tid;

void print_ids(const char *str) {
    pid_t pid;      //进程id
    pthread_t tid;  //线程id
    pid = getpid();       //获取当前进程id
    tid = pthread_self(); //获取当前线程id
    printf("%s pid: %u tid: %u (0x%x)\n",
           str, (unsigned int) pid, (unsigned int) tid, (unsigned int) tid);
}

void *func(void *arg) {
    print_ids("new  thread:");
    return ((void *) 0);
}

int main() {
    int err;
    err = pthread_create(&main_tid, NULL, func, NULL); //创建线程
    if (err != 0) {
        printf("create thread error: %s/n", strerror(err));
        return 1;
    }
    printf("main thread: pid: %u tid: %u (0x%x)\n",
           (unsigned int) getpid(),
           (unsigned int) pthread_self(),
           (unsigned int) pthread_self());
    print_ids("main thread:");
    sleep(1);
    return 0;
}

在CMakeList.txt 最后加

find_package(Threads)

target_link_libraries(untitled1 ${CMAKE_THREAD_LIBS_INIT})

java

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer 
sudo apt install oracle-java8-set-default

ref

https://blog.csdn.net/ithomer/article/details/6063067

https://blog.csdn.net/ithomer/article/details/5920936