Win11之g++和build-essential的美妙甜甜圈
Posted zhangrelay
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Win11之g++和build-essential的美妙甜甜圈相关的知识,希望对你有一定的参考价值。
使用win11的ubuntu22.04子系统:
☞ Win11使用WSL2安装Ubuntu22.04并启用GUI应用
zhangrelay@LAPTOP-5REQ7K1L:~/cppcode$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
安装:
sudo apt install build-essential g++
zhangrelay@LAPTOP-5REQ7K1L:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1)
甜甜圈:
#include <stdio.h>
#include <math.h>
#include <cstring>
#include <unistd.h>
int main()
float A = 0, B = 0;
float i, j;
int k;
float z[1760];
char b[1760];
printf("\\x1b[2J");
for (;;)
memset(b, 32, 1760);
memset(z, 0, 7040);
for (j = 0; j < 6.28; j += 0.07)
for (i = 0; i < 6.28; i += 0.02)
float c = sin(i);
float d = cos(j);
float e = sin(A);
float f = sin(j);
float g = cos(A);
float h = d + 2;
float D = 1 / (c * h * e + f * g + 5);
float l = cos(i);
float m = cos(B);
float n = sin(B);
float t = c * h * g - f * e;
int x = 40 + 30 * D * (l * h * m - t * n);
int y = 12 + 15 * D * (l * h * n + t * m);
int o = x + 80 * y;
int N = 8 * ((f * e - c * d * g) * m - c * d * e - f * g - l * d * n);
if (22 > y && y > 0 && x > 0 && 80 > x && D > z[o])
z[o] = D;
b[o] = ".,-~:;=!*#$@"[N > 0 ? N : 0];
printf("\\x1b[H");
for (k = 0; k < 1761; k++)
putchar(k % 80 ? b[k] : 10);
A += 0.00004;
B += 0.00002;
usleep(30000);
return 0;
donut.cpp
g++ -std=c++20 donut.cpp -o donut
./donut
zhangrelay@LAPTOP-5REQ7K1L:~/cppcode$ history
1 sudo apt update
2 sudo apt upgrade
3 sudo apt install gedit
4 sudo apt install g++
5 sudo apt clean
6 sudo apt install gedit
7 gedit
8 sudo apt update
9 sudo apt upgrade
10 sudo apt install build-essential g++
11 gcc -v
12 g++-std=c++20
13 g++ -std=c++20
14 ls
15 cd /home/zhangrelay/
16 ls
17 mkdir cppcode
18 cd cppcode/
19 ls
20 gedit donut.cpp
21 g++ -std=c++20 donut.cpp -o donut
22 ./donut
23 history
zhangrelay@LAPTOP-5REQ7K1L:~/cppcode$
以上是关于Win11之g++和build-essential的美妙甜甜圈的主要内容,如果未能解决你的问题,请参考以下文章
debian 7.6 root@debian:~# apt-get install -y build-essential gcc g++ make 安装不成功