hongy19’s blog
GCC
some tips when i trying compile opengl programs in conda* g++ -I/home/hongy19/miniconda3/envs/opengl/include/ : include *.h
- g++ -L/home/hongy19/miniconda3/envs/opengl/lib :add folder of *.so for link(ld)
- g++ -lglfw: use libglfw.so for link(ld)
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hongy19/miniconda3/envs/opengl/lib ./a.out: add library search path for dynamic *.so
- static compile
- -static compile for static link need *.a and *.o library and *.so doesn’t work for static compile, see link. The error of following code is due to missing of *.a or *.o even *.so existed.
(opengl) hongy19@WSL opengl$ gcc glfw-1.cpp -static -lglfw -lGL
/usr/sbin/ld: cannot find -lglfw: No such file or directory
/usr/sbin/ld: cannot find -lGL: No such file or directory
collect2: error: ld returned 1 exit status
X11 and wayland
see Environment variables for Wayland hackers and Wayland-specific environment variables for detail and what is setting in wsl2.
- WAYLAND_DISPLAY
- wayland unix socket
- WAYLAND_DISPLAY=wayland-0
- XDG_RUNTIME_DIR
- directory of wayland unix socket
- XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir/ or XDG_RUNTIME_DIR=/run/user/1000/
- DISPLAY
- X11 unix socket
- DISPLAY=:0 and /tmp/.X11-unix/X0
- GDK_BACKEND
- it is better to set according to GTK backend selection, or why GTK cannot open display: :0
- If the special value of help is used, a GTK application will print the possible values it knows. see link.
gtk3/gtk3 in conda has disabled wayland support, see link. * with pygobject, GDK_BACKEND=wayland doesn’t work but chrome/weston-terminal is OK and pygobject is OK with GDK_BACKEND=wayland, x11 or GDK_BACKEND=x11.
…keyboard
According to Archlinux wiki and How Keys Are Turned Into Actions, here comes how keystroke information is transferred in computer.
- Keyboard send scancode to computer
- Linux kernel convert scancode to keycode
- Keyboard layout convert keycode to symbol/keysym
- Linux terminal convert keysym into ASCII sequences
And there are two types of key (see link )* Ordinary key, like “a”, “b”. we should use them to input text
- Special keys, which you would use to tell xterm to perform some action. They could not be to used to input text. They will generate escape sequences.
.inputrc is readline initialization file and used to map key sequence to readline function like “end-of-history”. Then you need to use text to describe “special keys” or “escape sequences”, see following example.* “\e[1~”: beginning-of-line # Home Key
…